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.
In the case the facet field alias contains a colon (which do most entity api implemented fields), the facet filters aren't removed due to a missmatch on the rawurlencoded and rawurldecoded version of the field alias.
I will post a patch for that in the next comment.
Comment | File | Size | Author |
---|---|---|---|
#17 | facetapi-processactiveitems-phpnotice.patch | 992 bytes | Adam Clarey |
#6 | 1884152-processactiveitems-addactivefilters-6.patch | 563 bytes | duozersk |
#1 | facetapi-rawurlencoded_filter_alias-1884152-1.patch | 768 bytes | derhasi |
Comments
Comment #1
derhasi CreditAttribution: derhasi commentedAnd there is the patch.
Comment #2
derhasi CreditAttribution: derhasi commentedThe patch is applied relative to current 7.x-1.x-dev.
Comment #3
cpliakas CreditAttribution: cpliakas commentedThanks for the patch! This makes sense to me, will test it out soon.
Comment #4
duozerskI have recently created another issue with a patch for this bug - #2206649: processActiveItems() / addActiveFilters() compatibility
I have opted to fix it another way - will close it now as duplicate and post another patch here.
Thanks
AndyB
Comment #5
duozerskHere is a patch from #2206649: processActiveItems() / addActiveFilters() compatibility
Comment #6
duozerskHere as another version of the patch in #5 - without using any additional calls to rawurldecode/rawurlencode functions.
Thanks
AndyB
Comment #7
duozerskComment #8
duozerskComment #9
cpliakas CreditAttribution: cpliakas commentedHi duozersk.
I am not seeing the issue mentioned in the OP. Could you provide steps to reproduce on a clean install of Drupal w/ implementing search modules in order to highlight the bug?
Thanks,
Chris
Comment #10
duozerskChris,
I have made a demo on http://andrewberezovsky.ru/demo/demotest/
It uses the Facet API, Search API, Search API DB and Facet API Bonus modules. There is a dependency set on the facets (Brand and Model are 2 separate taxonomy vocabularies) - show Model facet only after selecting any value in the Brand facet (and remove the Model facet value after removing the Brand facet value).
The bug is that if after selecting the Brand and Model you remove the Brand facet value - then the Model is not removed from the Current search block and the breadcrumbs.
The reason for this bug is explained in the referenced issue - #2206649: processActiveItems() / addActiveFilters() compatibility
"The processActiveItems() uses the raw, not urldecoded key to set the $this->activeItems['filter'][__KEY__] while addActiveFilters() tries to remove the facet that didn't meet the dependencies using the 'field alias' key which is urldecoded."
Hope it helps.
AndyB
Comment #11
cpliakas CreditAttribution: cpliakas commentedHi duozersk .
Thanks for taking the time to set up the demo. The bug is crystal clear to me now, and your description has helped me to replicate it locally as well. Marking your patch in #6 as RTBC as I can confirm that it fixes the issue.
Thanks for the contribution and efforts to help me understand the bug,
Chris
Comment #14
cpliakas CreditAttribution: cpliakas commentedComment #15
duozerskGreat!
Thank you for coming back to this issue, really appreciate your efforts on Facet API.
Comment #17
Adam Clarey CreditAttribution: Adam Clarey as a volunteer commentedI've attached a patch to prevent php notices occurring when the $parts array only contains a single item by declaring $filter within the if statement.
Comment #18
drummSee #2378693: Notice: Undefined offset: 1 in FacetapiAdapter->processActiveItems() line 312 for fixing the notice.