-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Admin searches in WooCommerce taxonomies return no results #2817
Merged
Conversation
This file contains 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
burhandodhy
commented
Jun 3, 2022
* Support meta_key | ||
* | ||
* @since 2.1 | ||
* Support `meta_key`, `meta_value`, and `meta_compare` query args | ||
*/ | ||
if ( ! empty( $args['meta_key'] ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't add meta_key
if meta_value
is not set.
burhandodhy
commented
Jun 3, 2022
@@ -478,7 +478,7 @@ public function format_args( $query_vars ) { | |||
'key' => $query_vars['meta_key'], | |||
]; | |||
|
|||
if ( isset( $query_vars['meta_value'] ) ) { | |||
if ( isset( $query_vars['meta_value'] ) && '' !== $query_vars['meta_value'] ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only want to pass meta_value
to ES if its value is not empty
Fix Linting issues
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 of the Change
This PR fixes the issue where the EP returns incorrect result when the
meta_value
key is not set inWP_Query
andWP_Term_Query
.When the
meta_value
is not set, WordPress runs the exact SQL query that it runs in case of themeta_compare => 'Exists'
and when themeta_value
is empty, WordPress only returns the posts where the meta value is empty. This statement is only true for theWP Query
and not for theTerm Query
For the
Term Query
, WordPress runs the same query either themeta_value
is set to empty or its not set. The query in both cases is exact what we have in the case ofExists
. To tackle this case, I added another check that check if themeta_value
is not empty indexable Term classCloses #2791
Possible Drawbacks
I didn't find any negative impact. I tried to test all the cases and its working fine.
Verification Process
ep_integrate
line and run it again. In both cases result should be sameWP_Query
. Run the below code twice. First without EP and second time with EP integration. In both case the result should be same.Clothing
Checklist:
Changelog Entry
Fixed - Meta queries with 'exists' as compare operator and empty meta values handling
Credits
Props @burhandodhy