Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When executing a search that also includes a filter that is not a facet the generated URLs are errorneously added as 'n-facet' as opposed to the original fields.
Steps to reproduce
Configure a facet to appear in the results.
Execute a search using a filter that isn't configured as a facet.
Generated URLs should have the filter present in them as well as the facet to be applied.
Proposed resolution
When getUrlAliasByFacetId or getFacetIdByUrlAlias returns FALSE use the raw field value.
Comment | File | Size | Author |
---|---|---|---|
#11 | 3176923-11.patch | 5.85 KB | mglaman |
#11 | 3176923-test-only.patch | 3.53 KB | mglaman |
#9 | 3176923-9.patch | 3.17 KB | mglaman |
#9 | interdiff-3176923-5-9.txt | 2.08 KB | mglaman |
#2 | jsonapi_search_api-3176923-2.patch | 2.99 KB | JordanDukart |
Comments
Comment #2
JordanDukart CreditAttribution: JordanDukart as a volunteer commentedAttaching patch that fixes this issue + random coding standards clean up.
Comment #3
mglamanI just hit this as well, giving it a test run
Comment #4
mglamanWe need to get some test coverage added.
I had the given existing filter:
The term URL provided for a color facet on BLACK returned:
This broke the existing filter conditions
Comment #5
mglamanHere is a new patch which preserves all non-facet filter params and passes them to the built URL for each facet result.
Comment #6
mglamanDefinitely need to get a test in there.
Comment #7
mglamanThis isn't quite right yet.
Original
Generated
We're missing the [group] and [condition] parameters.
Comment #8
mglamanAh, here it is:
The logic which rewrites into filters needs to be visited.
Comment #9
mglamanThis did the trick. Using the original filters when rebuilding that query key.
Comment #10
JordanDukart CreditAttribution: JordanDukart as a volunteer commentedThis is awesome @mglaman! Pulled in the patch locally, preserves the original non-facet based filters as it should. Only thing I can see is some nit coding standards things:
Think the module ones were introduced in the form_alter improvements but nbd either way.
Comment #11
mglamanThanks @JordanDukart! Here's a patch with a test-only run. And the fix+test. And phpcs fixes.
Comment #12
mglamanGoing to merge after lunch 🥳
Comment #14
mglaman🥳 Committed
Comment #15
JordanDukart CreditAttribution: JordanDukart commented🥳