Problem/Motivation
jsonapi_views_views_preview_info_alter() is checking for exposed filters by field name instead of by identifier.
When previewing a JSON:API Views -enabled view with an exposed filter, the log shows warnings like the following for each exposed filter:
Warning: Undefined array key "created" in jsonapi_views_views_preview_info_alter() (line 43 of web/modules/contrib/jsonapi_views/jsonapi_views.module)
Steps to reproduce
- Create a view on nodes and ensure that "Exposed via JSON:API" is set to "Yes".
- Add a filter on a node field, make it exposed, and set its [required] "Filter identifier".
- Preview the view below.
The filter won't show up in the URL in the "JSON:API Views", and there will be a warning like the above in the site log.
Proposed resolution
Check for filter identifier instead of just field name.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | jsonapi_views-use_filter_identifier-3376193-3.patch | 922 bytes | jeffschuler |
| #2 | jsonapi_views-use_filter_identifier-3376193-2.patch | 915 bytes | jeffschuler |
Issue fork jsonapi_views-3376193
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
jeffschulerComment #3
jeffschulerMissed an
isset().Comment #4
nuuou commented+1 on this. Ran into this exact same issue on a handful of projects, and this fixed it for me!
Comment #5
anybody@jeffschuler thanks, this is an important fix! Could someone maybe turn the patch from #3 into a MR and add tests?
Comment #6
anybodyTurned #3 into a MR to speed things up.
Comment #8
anybodyFYI: #3277489: Undefined index: XXX in jsonapi_views_views_preview_info_alter() is a duplicate with a different approach.
Comment #13
decipheredThanks all, this is fixed and committed for the upcoming 8.x-1.2 release.