[wp-trac] [WordPress Trac] #35624: Use of get_comment() function shows Notice

WordPress Trac noreply at wordpress.org
Wed Jan 27 08:42:36 UTC 2016


#35624: Use of get_comment() function shows Notice
--------------------------+-----------------------------
 Reporter:  WisdmLabs     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:  4.4.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 The '''get_comment_ID()'''
 https://codex.wordpress.org/Function_Reference/get_comment_ID function
 throws following Notice while calling -


 {{{
 Trying to get property of non-object in <WP DIR>/wp-includes/comment-
 template.php on line 646
 }}}


 I see that this function internally makes call to the '''get_comment()'''
 https://codex.wordpress.org/Function_Reference/get_comment function which
 supposed to be a parameterized function.

 When '''get_comment()''' (without parameter) is used, it returns nothing
 (not even any warning, error or notice) but when it is used somewhere else
 in a variable which is then used as an object to retrieve something from
 it, it shows the Notice. ''Obviously, since there is no value in it, it
 would be showing the Notice''.

 e.g. '''$comment->comment_ID''' at
 [https://core.trac.wordpress.org/browser/tags/4.4.1/src/wp-includes
 /comment-template.php#L646]

 '''$comment->comment_author_email''' at
 [https://core.trac.wordpress.org/browser/tags/4.4.1/src/wp-includes
 /comment-template.php#L183]

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


More information about the wp-trac mailing list