[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 22:58:29 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):
@johnjamesjacoby Here?
{{{#!php
<?php
$id = 0;
$post = get_post( $id );
}}}
That's not mocking an empty `WP_Post` object, is it? That seems to be just
another way of doing `$post = get_post()` since an ID of `0` will result
in the global `$post` being used. But if that global doesn't exist, then
`$post->comment_count` would still issue a warning.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63263#comment:23>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list