[wp-trac] [WordPress Trac] #45811: debug warnings generated on 404 feed
WordPress Trac
noreply at wordpress.org
Wed Jan 2 20:59:30 UTC 2019
#45811: debug warnings generated on 404 feed
--------------------------+------------------------------
Reporter: wpmuguru | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 5.0.2
Severity: minor | Resolution:
Keywords: needs-patch | Focuses:
--------------------------+------------------------------
Comment (by peterwilsoncc):
This problem occurs because `\WP_Query::is_singular()` does not check if
`get_queried_object()` returns `null` before checking for
`get_queried_object()->post_type`.
Adding a check to the core function beforehand should solve the problem. I
will need to check if it's needed for `\WP_Query::is_single()` and other
related functions.
Others will know the history of `is_singular()` better than I, so I will
leave it for someone else to decide if a fix should go into core.
---
@wpmuguru FYI: I hit this bug recently for the `template_redirect` hook
and worked around it with the code:
{{{#!php
<?php
if ( get_queried_object() === null && ! is_singular( 'post_type' ) ) {
return;
}
/* Function code */
}}}
But you've probably figured that out :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45811#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list