- Issue created by @Anybody
- π©πͺGermany Anybody Porta Westfalica
I was able to quickfix this using a fallback empty array, if null:
$this->value = array_values($active_facet_values ?? []);
Any ideas about the root cause? Is this an appropriate fix?
- Merge request !251Update FacetsFilter.php: Add fallback array, if $active_facet_values is NULL β (Open) created by Anybody
- π§πͺBelgium StryKaizer Belgium
Hmm, interesting.
You would need to debug this in getActiveFacetValues() in modules/facets_exposed_filters/src/Plugin/views/filter/FacetsFilter.phpI wonder why this function returns NULL in your case.
- πΊπΈUnited States MegaKeegMan
I experienced the same issue and the issue fork resolved it for me.
- π§πͺBelgium StryKaizer Belgium
While I dont mind committing the above, I'd rather find out why this value is null.
Anyone having this issue who could debug?I can't reproduce this myself.
Does this happen on existing views + facets exposed filters only? Or also on newly created views + facets exposed filters?
- π©πͺGermany Anybody Porta Westfalica
@strykaizer:
getActiveFacetValues()
in my case always directy returns[]
from these lines:if (!isset($_GET[$this->options["expose"]["identifier"]])) { return []; }
- π©πͺGermany Anybody Porta Westfalica
aaaaaaaaah I found it!!
It's a logical mistake in code:
if($processed_facet) { $facet = $processed_facet; } else { /** @var \Drupal\facets\FacetInterface $facet */ $facet = $this->getFacet(); $results = []; $active_facet_values = $this->getActiveFacetValues(); // <<<<<<<<<< $active_facet_values is only defined here! [...] }
but
$this->value = array_values($active_facet_values);
is called AFTER the if / else, so $active_facet_values can be undefined!
Which PHP Version are you using @strykaizer? I guess an older one?
- π©πͺGermany Anybody Porta Westfalica
@strykaizer I created a further branch to fix this, but I'm unsure about one of the following fixed to correct this:
1. Move$this->value = array_values($active_facet_values);
into the else
2. Move$active_facet_values = $this->getActiveFacetValues();
before the if / else
3. Define$active_facet_values = [];
before the if/else - π§πͺBelgium StryKaizer Belgium
Ic, I assume you are placing your "exposed filters" in a block in that case?
Thanks for debugging, I'll fix this asap! -
strykaizer β
committed 94a0223f on 3.0.x
Issue #3485860 by anybody, strykaizer: TypeError: array_values():...
-
strykaizer β
committed 94a0223f on 3.0.x
Automatically closed - issue fixed for 2 weeks with no activity.