- Issue created by @seth.e.shaw
- π§πΎBelarus VasiliyRepin Minsk
Thank you for your report! I will test it soon.
When making a search where the number of facet results has a count less the the minimum it crashes with the watchdog error message: TypeError: array_merge(): Argument #1 must be of type array, null given in array_merge() (line 43 of /var/www/html/drupal/web/modules/contrib/facets_range_nouislider/src/Plugin/facets/widget/NoUiSliderWidget.php).
For example, I have a nouislider facet configured for year an item is created that has a count minimum of 2. If I provide a search with only a single result then this error is thrown. If I change the count minimum to 1 then the error disappears (but then the range slider is pointless, because there is only one possible value).
This is because the slider configuration has a null value due to the parent class returning an empty build when no results are available.
The following patch resolves the issue in my case (see also attached patch):
diff --git a/src/Plugin/facets/widget/NoUiSliderWidget.php b/src/Plugin/facets/widget/NoUiSliderWidget.php
index d237ddb..4691cb7 100644
--- a/src/Plugin/facets/widget/NoUiSliderWidget.php
+++ b/src/Plugin/facets/widget/NoUiSliderWidget.php
@@ -39,6 +39,9 @@ class NoUiSliderWidget extends SliderWidget {
$build = parent::build($facet);
$facet_settings = &$build['#attached']['drupalSettings']['facets']['sliders'][$facet->id()];
+ if (is_null($facet_settings)) {
+ return $build;
+ }
$facet_settings = array_merge($facet_settings, $this->getConfiguration());
Active
1.0
Code
Thank you for your report! I will test it soon.