Settings: save only searches that return a result, number of results

Created on 24 October 2017, about 7 years ago
Updated 6 January 2025, 3 days ago

Motivation

There is a use case for only saving search results that actually return at least one hit. Otherwise a malicious user could affect a publicly visible "top searches" block by searching for curse words (or the competitor's brand name).

To fix this, we could have a checkbox on a settings page that lets the site admin choose whether all searches should be saved or only the ones that return a hit.

The potential problem with this solution is that some undesirable words might still return a hit and would be unaffected by the additional requirement.

Proposed solution

* Move saving to db from hook_search_api_query_alter to hook_search_api_results_alter
* Create a settings page for indicating whether searches should be saved only if a result was returned
* Get access to query through ReslutSetInterface::getQuery in order to be able to save the search keys

I am going to throw together a patch for this, but I welcome your input. Please stop me if this has already been planned / discussed.

✨ Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇫🇮Finland jcalais

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024