Updated: Comment #0
Problem/Motivation
The remember selection setting in an exposed filter should only accept non-empty exposed input. When an exposed filter is grouped this is not the case and simply leaving an option as "All" (or -Any-) will remember the selection and run the view.
The bug will affect views that query large and complex data sets where using the required option is necessary for performance.
In Drupal 7, the bug was identified with the following steps:
- Create a View with an exposed grouped filter (for instance, a filter on user last login date with filter options less than or equal to zero (never logged in) and greater than zero (has logged in)). set it to remember the last setting the user gave this filter, and to be optional (so it will also have an "-Any-" (all) option).
- Set the View's exposed form to "input required"
- Log in as some ordinary user and visit the View once. the View will not yet return any results, which is expected, since it requires input. however:
- Visit the View a second time, still without having entered any input, and it will go ahead and execute its query and return results, because it incorrectly thinks you have provided input to the exposed grouped filter.
Proposed resolution
The root cause identified by user Olarin in the contrib views issue #2233695: optional exposed grouped filters on a View that requires exposed filters save their default values as remembered values when they shouldn't is that the return value for convertExposedInput() is inconsistent. The return value should be FALSE and not NULL in the case of required filters.
Remaining tasks
- Write a test that demonstrates the incorrect return value. A unit test may be suffice, but a functional test would work as well.
- Forward port the patch from Drupal 7 to Drupal 8
User interface changes
None.
API changes
Return value is consistently FALSE for FilterPluginBase::convertExposedInput().
Comments
Comment #1
mradcliffeNeither HandlerBase nor FilterPluginBase have proper API documentation for return value so this needs docs as well.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedAdding and removing groups is broken at the moment, see #2168893: Views filters groups adding and removing is broken.
I guess this is postponed until that issue is resolved.
Comment #3
mgiffordComment #14
quietone CreditAttribution: quietone at PreviousNext commentedI tested this on 9.4.x and was not able to reproduce this error. I followed the steps given in the Issue Summary.
Perhaps this was fixed years ago in #2168893: Views filters groups adding and removing is broken.
Therefore, closing as cannot reproduce. If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").
Thanks!