[wp-trac] [WordPress Trac] #63263: check if exists before accessing object properties of $post->comment_count

WordPress Trac noreply at wordpress.org
Wed Oct 22 17:46:44 UTC 2025


#63263: check if exists before accessing object properties of $post->comment_count
---------------------------------------------+--------------------------
 Reporter:  Presskopp                        |       Owner:  westonruter
     Type:  defect (bug)                     |      Status:  assigned
 Priority:  normal                           |   Milestone:  6.9
Component:  General                          |     Version:
 Severity:  normal                           |  Resolution:
 Keywords:  needs-test-info has-screenshots  |     Focuses:
---------------------------------------------+--------------------------

Comment (by westonruter):

 It wouldn't hurt to also include a `$post instanceof WP_Post` check as
 well, even though it is most likely that the global will have been set.
 There're no guarantees!

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


More information about the wp-trac mailing list