Make WordPress Core

Opened 7 years ago

Last modified 2 years ago

#42104 new defect (bug)

Tax query transformations unintentionally filtered by 'terms_clauses'

Reported by: chouby's profile Chouby Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9
Component: Taxonomy Keywords: has-patch
Focuses: Cc:


Since [40918] tax queries are transformed using WP_Term_Query. That's nice because the previously uncached query is now cached.

This however raises a backward compatibility issue as all existing filters applied to a term query are now unintentionnally applied to the tax query transformation.

The same kind of issue was raised by [38667], when the usage of WP_Term_Query was introduced in wp_get_object_terms(). However in this latest case, the unique presence of $args['object_ids'] in the arguments, not interpreted by WP_Term_Query, allows to differentiate term queries fired wp_get_object_terms(). There is no such unique argument which could serve the same purpose for the tax_query transformation.

I suggest to add a dummy parameter to the arguments of the query which would not be interpreted by the core and would only be useful to plugins to distinguish this query from others.

Attachments (2)

42104.patch (295 bytes) - added by Chouby 7 years ago.
42104.2.patch (600 bytes) - added by Chouby 2 years ago.
Add a new filter transform_query_args

Download all attachments as: .zip

Change History (4)

7 years ago

#1 @Chouby
7 years ago

  • Keywords has-patch added

2 years ago

Add a new filter transform_query_args

#2 @Chouby
2 years ago

To be consistent with what has been done with the filter wp_get_object_terms_args and the filter get_term_by_args I proposed in #54534 and term_exists_args I proposed in, I propose to handle the issue by introducing a new filter transform_query_args.

Note: See TracTickets for help on using tickets.