Skip to content

Fix exception which is thrown on search results page #30318

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

Merged
merged 5 commits into from
Oct 13, 2020
Merged

Fix exception which is thrown on search results page #30318

merged 5 commits into from
Oct 13, 2020

Conversation

wojtekn
Copy link
Contributor

@wojtekn wojtekn commented Oct 2, 2020

Description

PR fixes issue which results with throwing exception on search page when phrase contains slash (/).

Related Pull Requests

n/a

Fixed Issues (if relevant)

  1. Fixes SynonymAnalyzer.php in module-search is evaluating user input as a regex #25886
  2. Fixes Elasticsearch not able to search for term with a slash / in it #25110
  3. Fixes ElasticSearch breaks with / #28286

Manual testing scenarios

  1. Install clean Magento
  2. Ensure that Elasticsearch is enabled as search backend
  3. Ensure the synonym exists in SEO & Search -> Search Synonyms:
    foo,bar"foobar",
  4. Search for "Foo/Bar" in frontend

Without fix, the exception is thrown. PR ensures that generated phrases have preg modifiers escaped so exception won't be thrown.

Questions or comments

Fix was made inside private method. I'm not sure if any tests should be changed for that? Or regression test should be added?

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Oct 2, 2020

Hi @wojtekn. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@wojtekn
Copy link
Contributor Author

wojtekn commented Oct 2, 2020

I reviewed testGetSynonymsForPhrase and it was not including slash, so the buggy use case was not caught by that test.

I was able to make small modification to the test to cover for the change. Test fails when fix is not in place, it goes through when fix is applied.

@lbajsarowicz
Copy link
Contributor

@magento run all tests

@lbajsarowicz lbajsarowicz self-requested a review October 2, 2020 13:35
@rogyar rogyar assigned rogyar and unassigned rogyar Oct 2, 2020
@sidolov sidolov added Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Severity: S1 Affects critical data or functionality and forces users to employ a workaround. labels Oct 2, 2020
sidolov
sidolov previously approved these changes Oct 2, 2020
@magento-engcom-team
Copy link
Contributor

Hi @sidolov, thank you for the review.
ENGCOM-8303 has been created to process this Pull Request
✳️ @sidolov, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@sidolov sidolov added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Oct 2, 2020
@engcom-Alfa engcom-Alfa self-assigned this Oct 5, 2020
@engcom-Alfa
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @engcom-Alfa. Thank you for your request. I'm working on Magento instance for you.

Copy link
Contributor

@engcom-Alfa engcom-Alfa left a comment

Choose a reason for hiding this comment

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

Hi @wojtekn .

Could you fix failing tests?
Thanks!

@ghost ghost dismissed sidolov’s stale review October 5, 2020 08:11

Pull Request state was updated. Re-review required.

@engcom-Alfa
Copy link
Contributor

@wojtekn yes, the issue occurs if a phrase which contains not escaped slash will be passed to public
\Magento\Search\Model\SynonymAnalyzer::getSynonymsForPhrase method

Manual testing scenario:

  1. Ensure that Elasticsearch is enabled as search backend
  2. Ensure the synonym exists in SEO & Search -> Search Synonyms:
    foo,bar"foobar",
  3. Add phrase ('Foo/Bar') which contains not escaped slash to public
    \Magento\Search\Model\SynonymAnalyzer::getSynonymsForPhrase method

Before: ✖️ Search results in an error.

Screenshot from 2020-10-09 12-20-17

After: ✔️ Find that product without errors.

2020-10-09_12-32

@sivaschenko @lbajsarowicz @sidolov Could you take a look?

Thanks!

Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

I think we should deliver this fix

@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko, thank you for the review.
ENGCOM-8303 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

Hi @sidolov, thank you for the review.
ENGCOM-8303 has been created to process this Pull Request

@m2-assistant
Copy link

m2-assistant bot commented Oct 13, 2020

Hi @wojtekn, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@wojtekn wojtekn deleted the fix_search_results_page_exception branch October 13, 2020 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Component: Search Partner: Blue Acorn iCi partners-contribution Pull Request is created by Magento Partner Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: accept Release Line: 2.4 Severity: S1 Affects critical data or functionality and forces users to employ a workaround.
Projects
Archived in project
8 participants