Opened 6 years ago
Closed 6 years ago
#45811 closed defect (bug) (duplicate)
debug warnings generated on 404 feed
Reported by: | wpmuguru | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | 5.0.2 |
Component: | Query | Keywords: | |
Focuses: | Cc: |
Description
When a site has a plugin active that use is_singular
with a $post_type parameter in template_redirect (or similar hook) debug warnings of
PHP Notice: Trying to get property of non-object
when a non-existent /some-slug/feed/ url is requested.
Original discussion: https://github.com/woocommerce/woocommerce/issues/21756
Change History (2)
Note: See
TracTickets for help on using
tickets.
This problem occurs because
\WP_Query::is_singular()
does not check ifget_queried_object()
returnsnull
before checking forget_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:But you've probably figured that out :)