[wp-trac] [WordPress Trac] #33947: get_comment_class raises a PHP notice for non-registered users

WordPress Trac noreply at wordpress.org
Mon Sep 21 15:27:02 UTC 2015


#33947: get_comment_class raises a PHP notice for non-registered users
--------------------------+-----------------------------
 Reporter:  walterebert   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:  template      |
--------------------------+-----------------------------
 Calling the function `get_comment_class` raises a PHP notice, if a comment
 is from a non-registered user:

   Notice: Trying to get property of non-object in /srv/www/htdocs/wp-
 includes/comment-template.php on line 444

 I would propose to replace:
 {{{
 if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) )
 {
 }}}

 With:
 {{{
 if ( ! empty( $comment->user_id ) && $user = get_userdata(
 $comment->user_id ) ) {
 }}}

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


More information about the wp-trac mailing list