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

Fix: Facet returns no result for a term having accent characters #3031

Merged
merged 15 commits into from
Oct 21, 2022

Conversation

burhandodhy
Copy link
Contributor

@burhandodhy burhandodhy commented Sep 28, 2022

Description of the Change

This PR fixes the issue where the facet returns no result for a term having accent characters

Closes #3023

How to test the Change

  • Create a new category غير-مصنف
  • Assign some posts to new category
  • Go to frontend and select غير-مصنف from taxonomy widget
  • EP should returns the from غير-مصنف category

Changelog Entry

Fixed - Facet returns no result for a term having accent characters

Credits

Props @burhandodhy

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@burhandodhy burhandodhy changed the title Fix: Facet returns no result for non-english term Fix: Facet returns no result for a term having accent characters Sep 29, 2022
@burhandodhy burhandodhy marked this pull request as ready for review September 29, 2022 14:16
@burhandodhy burhandodhy added this to the 4.4.0 milestone Sep 29, 2022
@felipeelia
Copy link
Member

Facets e2e tests are consistently failing in this one @burhandodhy. Do you mind giving a look before we merge it? Thanks!

@felipeelia felipeelia assigned burhandodhy and unassigned felipeelia Oct 11, 2022
@burhandodhy
Copy link
Contributor Author

Facets e2e tests are consistently failing in this one @burhandodhy. Do you mind giving a look before we merge it? Thanks!

@felipeelia Tests are fixed. The problem was that the sanitize_title function was not a good choice for meta fields and sanitize_text_field for taxonomies. So to fix the problem, I introduced the new method sanitize_callback in classes. Now every class will have the ability to change the satanize function without effecting the other classes.

@felipeelia
Copy link
Member

@burhandodhy after giving this one a deeper look, it seems we might be going in the wrong direction. Instead of fixing the sanitization of the slug, your new code actually showed me we have a different problem:

If we create a post with a meta field with that same value, the meta facet will generate a URL with a different value than the taxonomy:

https://ep-es7.test/?ep_filter_category=%25d8%25ba%25d9%258a%25d8%25b1-%25d9%2585%25d8%25b5%25d9%2586%25d9%2581&ep_meta_filter_my_first_field=%D8%BA%D9%8A%D8%B1-%D9%85%D8%B5%D9%86%D9%81 (see how ep_filter_category is different from ep_meta_filter_my_first_field but they should be the same.)

Investigating it a little bit, it seems things work well if we use $term->name instead of $term->slug. Do you mind giving it another look? Feel free to ping me on slack to discuss the best way to move forward.

@felipeelia felipeelia assigned burhandodhy and unassigned felipeelia Oct 12, 2022
Copy link
Member

@felipeelia felipeelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@burhandodhy great progress on this one, thanks. I've left yet another comments/suggestions/changes here, let me know your thoughts about it.
One thing that I'm trying to do is to add unit tests for all filters/actions being called. Do you think it would be possible to add unit tests for these new filters as well? Thanks!

ps.: there is also a conflict with the facets e2e tests, if you don't mind fixing it.

includes/classes/Feature/Facets/FacetType.php Outdated Show resolved Hide resolved
includes/classes/Feature/Facets/Facets.php Outdated Show resolved Hide resolved
@burhandodhy
Copy link
Contributor Author

@felipeelia I made the changes that you requested. I also added the tests for the filters.

Copy link
Member

@felipeelia felipeelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are almost there, @burhandodhy!

tests/php/features/TestFacetTypeMeta.php Outdated Show resolved Hide resolved
tests/php/features/TestFacetTypeMeta.php Outdated Show resolved Hide resolved
tests/php/features/TestFacetTypeTaxonomy.php Outdated Show resolved Hide resolved
Copy link
Member

@felipeelia felipeelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the hard work on this one @burhandodhy!

@felipeelia felipeelia merged commit 7dd26d5 into develop Oct 21, 2022
@felipeelia felipeelia deleted the burhan/fix-3023 branch October 21, 2022 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Facet returns no result for a term having accent characters 
2 participants