Problem/Motivation
In the Entity Mesh view, the exposed filter select options are built dynamically from the current results shown in the table. This causes a stability issue.
If a value that was previously available in the system (and can still be referenced by a saved filter, URL parameter, or bookmarked view) later disappears from the current dataset, the exposed filter no longer contains that option. When the view is requested with that missing value, Views throws an error instead of returning an empty result set or a validation message.
Example: the Schema filter (HTTP/HTTPS/etc.) should be available independently of what is currently returned in the table, because it represents a known set of valid values.
Steps to reproduce
- Go to the Entity Mesh SME listing page (a Views table with exposed filters).
- Confirm an exposed select filter is populated from current results (e.g., **Schema**).
- Apply a filter value that exists (e.g., `schema=https`) and save/bookmark the filtered URL (or share it).
- Change the data so that the chosen value no longer appears in the current dataset (e.g., remove/update all items with `schema=https`, or change the field values).
- Load the previously saved/bookmarked URL that still contains the filter value.
- Observe that the view returns an error (instead of showing zero results or handling the value gracefully).
Proposed resolution
Ensure exposed filter options are **not derived from the current result set** when the filter represents a known, valid domain of values. The view should accept previously valid filter values without throwing an error.
Issue fork entity_mesh-3576679
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
lpeidro commentedComment #3
lpeidro commentedComment #6
nickolajOverrides `validate()` in `BaseSelectFilter` to strip out submitted exposed filter values that no longer exist in the database before calling the parent validation. This prevents the "illegal choice" error when a bookmarked URL contains a filter value whose matching data has since been removed — the view simply returns zero results instead.
Comment #7
lpeidro commentedHello @nickolaj, thank you for your contribution. I merge the branch.