Remove duplicate category_name, cat and tag_id from ES query when tax_query set#92
Merged
rinatkhaziev merged 3 commits intodevelopfrom Jun 22, 2021
Merged
Conversation
rinatkhaziev
approved these changes
Jun 11, 2021
|
Hiding whitespace changes is helpful, only 3 lines actually "changed" |
5 tasks
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Core has a funky backwards compat feature where category_name, cat and tag_id are set explicitly:
https://github.com/WordPress/WordPress/blob/5d99107bf3ab35aa3dda82c6b3903f5717771335/wp-includes/class-wp-query.php#L2193-L2215
However, this interferes with the ES query when tax_query is also set. For example, take this WP_Query to be offloaded:
What we would expect from this is posts with a tag of
toronto-trafficOR category oftrafficand post_tag oftoronto. The ES query would look like:However, ES currently returns the following query, where results that may only just have
trafficas a category are returned:It ends up treating the three conditions separately as an OR.
Checklist
Please make sure the items below have been covered before requesting a review:
Steps to Test
traffic.trafficand post_tagtoronto.toronto-traffic.