-
Notifications
You must be signed in to change notification settings - Fork 314
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
Exclude category taxonomy from root tax check #2299
Conversation
@oscarssanchez looks good. Do you mind in add a test if the key Something similar to https://github.com/10up/ElasticPress/blob/develop/tests/php/indexables/TestUser.php#L712 |
…fix/category-slug-bug
…into fix/category-slug-bug
tests/php/indexables/TestPost.php
Outdated
* @group post | ||
*/ | ||
public function testCatIdTaxQuery() { | ||
$term = Functions\create_and_sync_term( 'test', 'Test category', 'The testing category', 'category' ); |
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.
the PHPUnit is getting an error in this line Error: Call to a member function index() on bool
tests/php/indexables/TestPost.php
Outdated
); | ||
|
||
$this->assertContains( $term, $args['post_filter']['bool']['must'][0]['bool']['must'][0]['terms']['terms.category.term_id'] ); | ||
$this->assertNotContains( 'test', $args['post_filter']['bool']['must'][0]['bool']['must'][1]['terms']['terms.category.slug'] ); |
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 need to update the assertion because ['must'][1]['terms']['terms.category.slug']
doesn't exist and I think it'll always return true.
Maybe we need to check if the array $args['post_filter']['bool']['must'][0]['bool']['must']
has only one item (assertCount) and if this only item $args['post_filter']['bool']['must'][0]['bool']['must'][0]['terms']
has the key terms.category.term_id
(assertArrayHasKey).
Makes sense?
Description of the Change
Fixes #2242
As WordPress core sets the
category_name
parameter when performing a Tax Query if you are doing an id's search, this conflicts with this check EP does here: https://github.com/10up/ElasticPress/blob/develop/includes/classes/Indexable/Post/Post.php#L1003This problem only applies to the category taxonomy.
Alternate Designs
Benefits
Possible Drawbacks
Verification Process
Checklist:
Applicable Issues
Changelog Entry