[wp-trac] [WordPress Trac] #21394: query.php: get_queried_object() result cannot be assumed to be non-NULL
WordPress Trac
noreply at wordpress.org
Thu Jan 31 22:41:16 UTC 2013
#21394: query.php: get_queried_object() result cannot be assumed to be non-NULL
------------------------------+-----------------------------
Reporter: lkraav | Owner: wonderboymusic
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 3.6
Component: Warnings/Notices | Version: 3.3.2
Severity: normal | Resolution:
Keywords: has-patch |
------------------------------+-----------------------------
Comment (by lkraav):
Replying to [comment:6 ryan]:
> That patch adds a bunch of defensive checks, but we need to better
understand why a template tag is true but its corresponding queried object
is empty.
Good thing I did a search for is_page(), I was apparently about to file a
duplicate of this same thing.
Here's the scenario that causes the trifecta:
{{{
NOTICE: wp-includes/query.php:3348 - Trying to get property of non-object
NOTICE: wp-includes/query.php:3350 - Trying to get property of non-object
NOTICE: wp-includes/query.php:3352 - Trying to get property of non-object
}}}
This e-commerce plugin uses virtual pagename's for rewriting.
{{{/store/products/}}} gets translated to {{{pagename=product_list}}}
query:
{{{
$new_rules[$this->get_setting('slugs->store') . '/' .
$this->get_setting('slugs->products') . '/?$'] =
'index.php?pagename=product_list';
}}}
Then it has a {{{wp}}} action, that checks for {{{query_var ==
"product_list"}}} and builds up a "real" query with a {{{query_posts}}}
call.
Now Yoast's WP SEO plugin is actually the one causing these notices,
because for some reason it does {{{wp_reset_query()}}} in its {{{wp}}}
action {{{$this->metadesc()}}} handler. Why reset the query here, I do not
know, I'm not familiar at all with the innards of this plugin. Then WP SEO
hits the system with {{{is_front_page()}}} etc that passes through
{{{is_page()}}} with {{{$wp_the_query}}} (i.e. the original "virtual"
pagename) as its target.
So I am not sure how much understanding here is needed, but it seems real
world is somehow coming up with these ways to do things that causes
get_queried_object() to be null. It doesn't feel like what folks are doing
is too much off The Right Way either. Or...?
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21394#comment:9>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list