Skip to content
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

BUG: ep_post_match_fuzziness value overridden by default value of deprecated ep_match_fuzziness value #3033

Closed
marc-tt opened this issue Sep 29, 2022 · 2 comments · Fixed by #3037
Assignees
Labels
bug Something isn't working module:posts Issues related to the Posts Indexable / Feature.
Milestone

Comments

@marc-tt
Copy link

marc-tt commented Sep 29, 2022

Describe the bug

The deprecated filter ep_match_fuzziness is run after its replacement filter ep_post_match_fuzziness despite the first filter being defined with add_filter and returning a value.

As such, fuzziness is always set to "auto", the default value for the deprecated filter.

Steps to Reproduce

  1. Add the filter
add_filter('ep_post_match_fuzziness', function ($fuzziness): int {
  return 1;
});

When the search is performed this is called (Version_400.php line 87):

apply_filters( "ep_{$indexable_slug}_match_fuzziness", 'auto', $search_fields, $query_vars ),

Then this is called (Version_400.php line 162):

$query['bool']['should'][1]['multi_match']['fuzziness'] = apply_filters_deprecated(
  'ep_match_fuzziness',
  [ 'auto', $search_fields, $query_vars ],
  '4.3.0',
  'ep_post_match_fuzziness'
);

...which overrides the previous value to "auto".

Expected behavior

If the replacement filter is defined, then the deprecated filter should not be called.

Environment information

  • WordPress version: 6.0.2
  • ElasticPress version: 4.3.1
@marc-tt marc-tt added the bug Something isn't working label Sep 29, 2022
@kevinlisota
Copy link

I assume this is related to my question here

@felipeelia
Copy link
Member

Hey @marc-tt, thanks for opening the issue. I've created a PR changing a bit how those filters work and now the deprecated filters will honor the value set with the newer filters. And yes, @kevinlisota, that is related to your question, thanks for that.

@felipeelia felipeelia added the module:posts Issues related to the Posts Indexable / Feature. label Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module:posts Issues related to the Posts Indexable / Feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants