You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ElasticPress\Indexable\Term\QueryIntegration::maybe_filter_query (here) should short-circuit WP_Term_Query::get_terms() but when it doesn't find any term it returns null (as $new_terms is not defined) and WP keeps its process.
Steps to Reproduce
Execute the following code:
// Add the term but does not index to ES
add_filter( 'ep_term_sync_kill', '__return_true' );
wp_insert_term( 'mytestterm', 'category' );
remove_filter( 'ep_term_sync_kill', '__return_true' );
// Search for the term
$terms = new WP_Term_Query(
array(
'taxonomy' => 'category',
'search' => 'mytestterm',
'hide_empty' => false,
'ep_integrate' => true,
)
);
echo '<pre>';
print_r( $terms );
echo '</pre>';
The result will contain the term (without the elasticsearch attribute) but $terms will have elasticsearch_success set to 1 and found_terms as 0, as that is set by EP, that didn't find anything on ES.
Expected behavior
If nothing was found on ES but the request was successful, we should avoid fallback to MySQL.
Additional context
Setting $new_terms = []; before switch ( $fields ) { ensures we'll return at least an empty array rather than null. Although the solution is easy, we'll have to fix a lot of our unit tests.
The text was updated successfully, but these errors were encountered:
Describe the bug
ElasticPress\Indexable\Term\QueryIntegration::maybe_filter_query
(here) should short-circuitWP_Term_Query::get_terms()
but when it doesn't find any term it returns null (as$new_terms
is not defined) and WP keeps its process.Steps to Reproduce
Execute the following code:
The result will contain the term (without the
elasticsearch
attribute) but$terms
will haveelasticsearch_success
set to1
andfound_terms
as0
, as that is set by EP, that didn't find anything on ES.Expected behavior
If nothing was found on ES but the request was successful, we should avoid fallback to MySQL.
Additional context
Setting
$new_terms = [];
beforeswitch ( $fields ) {
ensures we'll return at least an empty array rather than null. Although the solution is easy, we'll have to fix a lot of our unit tests.The text was updated successfully, but these errors were encountered: