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

WordPress Trac noreply at wordpress.org
Fri Mar 18 11:36:12 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:  Awaiting Review
Component:  Users           |    Version:  5.9.2
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 If a post has been last modified by a removed author, method
 `get_the_modified_author` throws a warning:

 Warning: Attempt to read property "display_name" on bool in htdocs/wp-
 includes/author-template.php on line 104

 This happens because `get_userdata` returns false if the user that
 modified the post last no longer exists.

 A possible solution:

 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', $last_user ?
 $last_user->display_name : '' );`

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


More information about the wp-trac mailing list