[wp-trac] [WordPress Trac] #55420: Warning thrown by method get_the_modified_author if author was removed

WordPress Trac noreply at wordpress.org
Mon Mar 21 08:43:47 UTC 2022


#55420: Warning thrown by method get_the_modified_author if author was removed
---------------------------+-----------------------------
 Reporter:  juanlopez4691  |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  6.0
Component:  Users          |     Version:
 Severity:  normal         |  Resolution:
 Keywords:  has-patch      |     Focuses:  administration
---------------------------+-----------------------------

Comment (by juanlopez4691):

 @mukesh27 You can try as follows:
 1. Log in admin create a post with any existing user.
 2. Create a new user.
 3. Logout and login back as user /2/.
 4. Modify the post created in /1/
 5. Log out and login back as user /1/ (should have administrator role).
 6. Delete user #2.

 The result is:
 - `postmeta` field `_edit_last` for the modified post is still holding the
 removed user /2/.
 - Using method `get_the_modified_author` to retrieve the name of the user
 who last modified post #1 raises a warning, as described in the ticket.

 My proposed patch is just a defensive measure similar to what is applied
 in method `get_the_author_meta`, line 175 ([https://bit.ly/3N91DIi]).

 Another possible solution could be to modify file `wp-includes/author-
 template.php`, line 104, from
 `return apply_filters( 'the_modified_author', $last_user->display_name );`
 to
 `return apply_filters( 'the_modified_author', empty( $last_user ) ? '' :
 $last_user->display_name );`

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


More information about the wp-trac mailing list