From af50a07ce6862d907c9d8b2578897ffafbdabdc4 Mon Sep 17 00:00:00 2001 From: Ere Maijala <ere.maijala@helsinki.fi> Date: Tue, 21 Feb 2017 16:29:56 +0200 Subject: [PATCH] Avoid querying e.g. home page facets from the backend if none are enabled. (#925) --- .../src/VuFind/Controller/SearchController.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php index 14c77321407..daa540e6b68 100644 --- a/module/VuFind/src/VuFind/Controller/SearchController.php +++ b/module/VuFind/src/VuFind/Controller/SearchController.php @@ -581,11 +581,17 @@ class SearchController extends AbstractSearch $params = $results->getParams(); $params->$initMethod(); - // We only care about facet lists, so don't get any results (this helps - // prevent problems with serialized File_MARC objects in the cache): - $params->setLimit(0); - - $list = $results->getFacetList(); + // Avoid a backend request if there are no facets configured by the given + // init method. + if (!empty($params->getFacetConfig())) { + // We only care about facet lists, so don't get any results (this + // helps prevent problems with serialized File_MARC objects in the + // cache): + $params->setLimit(0); + $list = $results->getFacetList(); + } else { + $list = []; + } $cache->setItem($cacheName, $list); } -- GitLab