[wp-trac] [WordPress Trac] #63522: Warnings related to get_queried_object returning null
WordPress Trac
noreply at wordpress.org
Wed Jun 4 02:13:05 UTC 2025
#63522: Warnings related to get_queried_object returning null
----------------------------------------+------------------------------
Reporter: dd32 | Owner: (none)
Type: defect (bug) | Status: new
Priority: low | Milestone: Awaiting Review
Component: General | Version:
Severity: minor | Resolution:
Keywords: has-patch needs-unit-tests | Focuses:
----------------------------------------+------------------------------
Description changed by dd32:
Old description:
> Similar to #29660 and resolved for a lot of things in [54496],
> get_body_class() and wp_list_pages() throw many PHP warnings due to
> missing post objects when the request is singular, but no post is
> located.
>
> These include in `get_body_class()`:
> > E_WARNING: Attempt to read property "ID" on null in wp-includes/post-
> template.php:676
> > E_WARNING: Attempt to read property "post_type" on null in wp-includes
> /post-template.php:677
>
> and in `wp_list_pages():
> > E_WARNING: Attempt to read property "post_type" on null in wp-includes
> /post-template.php:1356
>
> and again in `feed_links_extra()`
> > E_WARNING: Attempt to read property "comment_count" on null in wp-
> includes/general-template.php:3351
> > E_WARNING: Attempt to read property "ID" on null in wp-includes
> /general-template.php:3359
> (although in this case, it's not get_queried_object(), just an
> expectation of `get_post(0)` working, which is effectively the same
> thing)
New description:
Similar to #29660 and resolved for a lot of things in [54496],
get_body_class() and wp_list_pages() throw many PHP warnings due to
missing post objects when the request is singular, but no post is located.
These include in `get_body_class()`:
> E_WARNING: Attempt to read property "ID" on null in wp-includes/post-
template.php:676
> E_WARNING: Attempt to read property "post_type" on null in wp-includes
/post-template.php:677
and in `wp_list_pages()`:
> E_WARNING: Attempt to read property "post_type" on null in wp-includes
/post-template.php:1356
and again in `feed_links_extra()`:
> E_WARNING: Attempt to read property "comment_count" on null in wp-
includes/general-template.php:3351
> E_WARNING: Attempt to read property "ID" on null in wp-includes/general-
template.php:3359
(although in this case, it's not get_queried_object(), just an expectation
of `get_post(0)` working, which is effectively the same thing)
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63522#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list