[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 18:02:38 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:  closed
 Priority:  normal             |   Milestone:
Component:  Posts, Post Types  |     Version:  trunk
 Severity:  normal             |  Resolution:  duplicate
 Keywords:                     |     Focuses:
-------------------------------+------------------------
Changes (by SergeyBiryukov):

 * status:  new => closed
 * component:  General => Posts, Post Types
 * milestone:  Awaiting Review =>
 * keywords:  needs-patch =>
 * resolution:   => duplicate


Old description:

> 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.

New description:

 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.

--

Comment:

 Hi @AkSDvP, welcome to WordPress Trac!

 Thanks for the report, we're already tracking this issue in #30991.

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


More information about the wp-trac mailing list