From f4063f2c47205821ef43f65734b1646f867b2bbc Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Wed, 4 Dec 2019 16:21:43 +0200
Subject: [PATCH] Check that recommendations exist for a given config location.
 (#1517)

- Otherwise an invalid location param causes an error.
---
 module/VuFind/src/VuFind/AjaxHandler/GetSideFacets.php | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/module/VuFind/src/VuFind/AjaxHandler/GetSideFacets.php b/module/VuFind/src/VuFind/AjaxHandler/GetSideFacets.php
index 4dacf600ae4..237b28cb781 100644
--- a/module/VuFind/src/VuFind/AjaxHandler/GetSideFacets.php
+++ b/module/VuFind/src/VuFind/AjaxHandler/GetSideFacets.php
@@ -132,7 +132,13 @@ class GetSideFacets extends \VuFind\AjaxHandler\AbstractBase
             return $this->formatResponse('', self::STATUS_HTTP_ERROR);
         }
 
-        $recommend = $results->getRecommendations($configLocation)[0];
+        $recommend = $results->getRecommendations($configLocation)[0] ?? null;
+        if (null === $recommend) {
+            return $this->formatResponse(
+                'Invalid config requested',
+                self::STATUS_HTTP_BAD_REQUEST
+            );
+        }
 
         $context = [
             'recommend' => $recommend,
-- 
GitLab