[wp-trac] [WordPress Trac] #60563: WP_Query::tax_query property could be null
WordPress Trac
noreply at wordpress.org
Tue Feb 20 11:11:47 UTC 2024
#60563: WP_Query::tax_query property could be null
-------------------------+-----------------------
Reporter: manooweb | Owner: audrasjb
Type: enhancement | Status: accepted
Priority: normal | Milestone: 6.5
Component: Query | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses: docs
-------------------------+-----------------------
Comment (by manooweb):
Replying to [comment:3 audrasjb]:
> @manooweb quick question: do you have any example of a situation where
`tax_query ` could be `null`?
It isn't so easy to reply.
If I'm not mistaken, I saw `tax_query` is set only in some conditions by
calling `WP_Query::parse_tax_query()` in `WP_Query::parse_query()` or
`WP_Query::get_posts()`. So it's possible that this property isn't set and
instantiate because `WP_Query::parse_tax_query()` isn't executed.
https://github.com/WordPress/WordPress/blob/6.4.3/wp-includes/class-wp-
query.php#L1372
It's simply a documentation proposition.
When we try to access to the global variable `$wp_query` (or
`$wp_the_query`) we have no chance to know the `tax_query` property has
been set yet because this property isn't set by the `WP_Query`
instantiation but during the `WP_Query::get_posts()` execution.
I hope it's clearer.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60563#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list