Module throws an error if the first facet doesn't have any item in for a particular filter.
Fatal error: Call to a member function getUrl() on boolean in /var/www/*****/docroot/modules/contrib/facets/modules/facets_summary/src/Plugin/facets_summary/processor/ResetFacetsProcessor.php on line 61
Scenario:
1. We got one content type called product with two fields color and price.
2. Suppose out of many products one product color field is empty and the price is available.
3. And price facet shows two elements 100(2) and 200(1). And one item which is coming in 200 doesn't have color field filled.
4. If user select 200(1) in price facts then modules throws an error.
The module is trying to get the url from the first facet and for this face "Empty facet behavior" is set to "Do not display facet".
Comments
Comment #2
gbisht commentedComment #3
gbisht commentedThe code is trying to run getUrl() on an empty array. The reason for this being empty is reset() which sets the pointer to the first item in the array and the first item is blank array as its empty and set to "Do not show facet".
Here is the patch to fix this issue.
Comment #4
gbisht commentedPatch file updated.
Comment #5
borisson_Setting to needs review, but will need a new test to prove that this actually fixes it.
Comment #6
borisson_Back to needs work for the test, so we can see that this actually fixes the behavior.
Comment #7
borisson_Setting the component to facet summary.
We need to add a new test to
\Drupal\Tests\facets_summary\Functional\IntegrationTestor extend::testMultipleFacetsin that class to actually test this.Comment #8
borisson_Does the patch in #2878851: Facet summary "Show a summary of all selected facets" values resolve your problem?
Comment #9
sylus commentedI have the other corresponding patch applied but occasionally I have fun into this exact same error.
The current patch did resolve my issues and I haven't been able to reproduce for the moment.
Comment #10
borisson_@sylus @gulab.bisht: I don't have a live site with facets to test this on, I only have my dev-site and haven't seen this behavior yet. Would it be possible to add a test for this (or steps to reproduce that use core fields)
Comment #11
kamkejj commentedI ran into the same error and this patch fixed it. The site has commerce with a lot of products and not sure how to reproduce.
Comment #12
borisson_I can't reproduce this in a test.
Comment #14
borisson_I can't reproduce this in the test I added, so until we get instructions on how to actually reproduce this in a testable way, we can't continue work on this.
Comment #15
mpp commentedWe also experienced this issue.
We have a multilingual setup with 2 facets (hierarchical categories & tags).
As soon as a "tag" filter becomes active, we see the error, weirdly it doesn't occur for the "category" filter.
Here's our config:
Tags facet:
Category facet:
Comment #16
mpp commentedComment #17
dragos-dumi commentedComment #18
dragos-dumi commentedAttached test to reproduce the error and the patch to fix this - different solution than #4
removing using the first facet item link - using uri from request.
Comment #20
borisson_This looks really great! Thanks @dragos-dumi!
Comment #21
borisson_