Opened 9 years ago
Closed 9 years ago
#37962 closed defect (bug) (fixed)
NOT EXISTS tax_query triggers debug notice on get_queried_object()
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | 3.8 |
Component: | Taxonomy | Keywords: | has-patch has-screenshots |
Focuses: | Cc: |
Description
When querying for post objects without taxonomy terms, a debug notice is triggered. (This doesn't happen with the built-in taxonomies, because they have old weird special-casing.)
Notice: Undefined index: terms in /srv/www/wordpress-develop/src/wp-includes/class-wp-query.php on line 3267
Example code:
add_action( 'admin_init', function() { $posts = new WP_Query( array( 'post_type' => 'event', 'tax_query' => array( array( 'taxonomy' => 'event-category', 'operator' => 'NOT EXISTS', 'include_children' => false ) ) ) ); var_dump( $posts->get_queried_object() ); die; } );
Patch imminent.
Attachments (2)
Change History (6)
#1
@
9 years ago
Last touch was r26874, which is possibly what revealed this notice, but not when the logical error was introduced.
NOT EXISTS
queries will never return terms
, so it makes sense that it would not be set at this time.
#2
@
9 years ago
- Milestone changed from Awaiting Review to 4.7
- Owner set to boonebgorges
- Status changed from new to assigned
Thanks for the patch. Looks good to me.
This raises a semi-related issue, which is that the change in [30711] renders the wp_list_filter()
just above this block superfluous; there's no point in filtering terms (rather than clauses) by operator
, and in any case, queried_terms
always necessarily contains the matched terms rather than not-matched terms. I'll pull that out under the guise of the current ticket as well.
Screenshot of xdebug output