WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 3 months ago

#47836 closed defect (bug) (duplicate)

PHP Notice: Undefined property: stdClass::$delete_posts in wp-admin/includes/class-wp-posts-list-table.ph file

Reported by: AkSDvP Owned by:
Milestone: Priority: normal
Severity: normal Version: trunk
Component: Posts, Post Types Keywords:
Focuses: Cc:
PR Number:

Description (last modified by SergeyBiryukov)

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.

Change History (1)

#1 @SergeyBiryukov
3 months ago

  • Component changed from General to Posts, Post Types
  • Description modified (diff)
  • Keywords needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi @AkSDvP, welcome to WordPress Trac!

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

Note: See TracTickets for help on using tickets.