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

Stop caching autosuggest requests #3566

Merged
merged 4 commits into from
Aug 1, 2023
Merged

Stop caching autosuggest requests #3566

merged 4 commits into from
Aug 1, 2023

Conversation

felipeelia
Copy link
Member

@felipeelia felipeelia commented Jul 28, 2023

Description of the Change

This PR changes the way authenticated requests for autosuggest are fired. These requests are used so the Elasticsearch hosting provider (EP.io, for example) knows which parameters are allowed in a query sent via JS, preventing anonymous users to send a query asking for shop orders, for example.

In #1890 (EP 3.5.2, in 2020) we introduced an authenticated request sent before the sync is started and when the weighting dashboard is saved. This request has a header EP-Set-Autosuggest=true. Before that, any request sending ep-search-term=search test or ep-search-term=ep_autosuggest_placeholder would set those values. To avoid sending a request per page load, EP cached the request sent.

The way we were caching it depended on the presence or absence of an external object cache: if present, we would cache a request per different query, if absent, we would just cache one query. Although that was made to allow for different autosuggest queries, it really doesn't fix the problem, as we can only have one set of allowed parameters.

This PR removes those cached requests, only sending a request to set allowed parameters before a sync or when the weighting dashboard is saved. If people want to run different autosuggest queries with different sets of allowed parameters, they can pass the superset of parameters (including everything) using the ep_autosuggest_query_args filter and checking if $_GET['ep_epio_set_autosuggest'] is set and is not empty.

Closes #2887

How to test the Change

Changelog Entry

Changed - Autosuggest authenticated requests are not cached anymore and are only sent during the sync process or when the weighting dashboard is saved.

Credits

Props @felipeelia @kovshenin

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.

@felipeelia felipeelia added this to the 4.7.0 milestone Jul 28, 2023
@felipeelia felipeelia merged commit b1afb82 into develop Aug 1, 2023
@felipeelia felipeelia deleted the fix/issue-2887 branch August 1, 2023 20:49
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.

Some feedback and ideas around the dummy request in Autosuggest.php
1 participant