#51370 closed defect (bug) (fixed)
Errors in the wp_dropdown_users() function when specifying a non-existent user
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.6 | Priority: | normal |
Severity: | normal | Version: | 5.5.1 |
Component: | Posts, Post Types | Keywords: | has-patch |
Focuses: | Cc: |
Description
Hello!
When editing a page whose author was deleted in the classic editor, the metabox with the author's choice generates a "Notice"error.
When the Metabox is called by the post_author_meta_box () function, the wp_dropdown_users () function is run, where one of the parameters is:
'selected' => empty( $post->ID ) ? $user_ID : $post->post_author,
This causes the following section of code to run:
$users[] = get_userdata( $parsed_args['selected'] );
But since the page author is deleted, get_userdata() returns false and the data will still be added to the list of users, which generates an error when composing user data, since the code expects an object of the WP_User class.
Example of an error in the log file:
Trying to get property 'display_name' of non-object in ..\wp-includes\user.php on line 1208 Trying to get property 'user_login' of non-object in ..\wp-includes\user.php on line 1208 Trying to get property 'ID' of non-object in ..\wp-includes\user.php on line 1215 Trying to get property 'ID' of non-object in ..\wp-includes\user.php on line 1216
Change History (4)
This ticket was mentioned in PR #545 on WordPress/wordpress-develop by campusboy87.
4 years ago
#1
- Keywords has-patch added
#2
@
4 years ago
- Milestone changed from Awaiting Review to 5.6
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
dream-encode commented on PR #545:
4 years ago
#4
Merged into WP Core in https://core.trac.wordpress.org/changeset/49036
Added a check for the existence of a user, since the function can get the ID of the user (for example, the author of the page) that was deleted.
Trac ticket: https://core.trac.wordpress.org/ticket/51370