[wp-trac] [WordPress Trac] #54379: `get_comment_ID()` can cause a notice within the `comment_text` filter

WordPress Trac noreply at wordpress.org
Fri Nov 5 01:24:19 UTC 2021


#54379: `get_comment_ID()` can cause a notice within the `comment_text` filter
--------------------------+------------------------------
 Reporter:  dd32          |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Comments      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by dd32):

 > Most of the comment template functions are written with the expectation
 that get_comment() will always return a non-false value

 Other examples:
 {{{
 E_NOTICE: Trying to get property 'comment_status' of non-object in wp-
 includes/comment-template.php:1244
 E_NOTICE: Trying to get property 'ping_status' of non-object in wp-
 includes/comment-template.php:1274
 }}}
 In those cases the `$post` object is expected to exist. See
 [attachment:"54379.comments_open.diff"]. Seems to primarily happen during
 the `jp_sitemap_cron_hook` cron event, so I'm guessing it's specifically
 for comments that relate to post_id = 0.

 {{{
 E_NOTICE: Trying to get property 'user_id' of non-object in wp-includes
 /comment-template.php:28
 E_NOTICE: Trying to get property 'comment_ID' of non-object in wp-includes
 /comment-template.php:48
 }}}
 Those are when `get_comment_author()` is called without a valid comment
 set, similar to the original issue here. See
 [attachment:"54379.get_comment_author.diff"]

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


More information about the wp-trac mailing list