[wp-trac] [WordPress Trac] #47836: PHP Notice: Undefined property: stdClass::$delete_posts in wp-admin/includes/class-wp-posts-list-table.ph file

WordPress Trac noreply at wordpress.org
Mon Aug 5 14:10:30 UTC 2019


#47836: PHP Notice: Undefined property: stdClass::$delete_posts in wp-
admin/includes/class-wp-posts-list-table.ph file
--------------------------+-----------------------------
 Reporter:  AkSDvP        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:  needs-patch
  Focuses:                |
--------------------------+-----------------------------
 Hi Team,

 Following PHP warning is being observed while rendering Manage Posts links
 in the admin section.

 PHP Notice:  Undefined property: stdClass::$delete_posts in /var/www/html
 /wp-sandbox/wp-admin/includes/class-wp-posts-list-table.php on line 413

 I would suggest to include isset() check statement to check if
 ($post_type_obj->cap->delete_posts) exists, before the current condition,
 that I think will handle the warning.

 So I suggest modifying the following code -

                 if ( current_user_can( $post_type_obj->cap->delete_posts )
 ) {
                         if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) {
                                 $actions['delete'] = __( 'Delete
 Permanently' );
                         } else {
                                 $actions['trash'] = __( 'Move to Trash' );
                         }
                 }

 with

                 if ( isset( $post_type_obj->cap->delete_posts ) ) {

                         if ( current_user_can(
 $post_type_obj->cap->delete_posts ) ) {
                                 if ( $this->is_trash || ! EMPTY_TRASH_DAYS
 ) {
                                         $actions['delete'] = __( 'Delete
 Permanently' );
                                 } else {
                                         $actions['trash'] = __( 'Move to
 Trash' );
                                 }
                         }
                 }

 Please find the source code link for reference.

 https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-
 wp-posts-list-table.php#L413

 Kindly advise if this can be considered to be addressed.

 Thanks.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47836>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list