From 71884204026c4d0a0c417ee6931c9a5081c00862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lahmann?= <lahmann@ub.uni-leipzig.de> Date: Mon, 2 Feb 2015 09:40:24 -0500 Subject: [PATCH] Sharding fixes * replaced not_null check of initialized array in VuFind\Search\Solr\Params * eliminated warning/added comments in VuFind\Search\Solr\MultiIndexListener --- .../VuFind/src/VuFind/Search/Solr/MultiIndexListener.php | 9 ++++++++- module/VuFind/src/VuFind/Search/Solr/Params.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/module/VuFind/src/VuFind/Search/Solr/MultiIndexListener.php b/module/VuFind/src/VuFind/Search/Solr/MultiIndexListener.php index 36502f9cf85..dfbacd5d5fa 100644 --- a/module/VuFind/src/VuFind/Search/Solr/MultiIndexListener.php +++ b/module/VuFind/src/VuFind/Search/Solr/MultiIndexListener.php @@ -124,7 +124,14 @@ class MultiIndexListener } else { // In any other context, we should make sure our field values are // all legal. - $shards = explode(',', implode(',', $params->get('shards'))); + + // Normalize array of strings containing comma-separated values to + // simple array of values; check if $params->get('shards') returns + // an array to prevent invalid argument warnings. + $shards = $params->get('shards'); + $shards = explode( + ',', implode(',', (is_array($shards) ? $shards : array())) + ); $fields = $this->getFields($shards); $specs = $this->getSearchSpecs($fields); $backend->getQueryBuilder()->setSpecs($specs); diff --git a/module/VuFind/src/VuFind/Search/Solr/Params.php b/module/VuFind/src/VuFind/Search/Solr/Params.php index 3172d8cd4ea..f63adb426cc 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Params.php +++ b/module/VuFind/src/VuFind/Search/Solr/Params.php @@ -459,7 +459,7 @@ class Params extends \VuFind\Search\Base\Params // Shards $allShards = $this->getOptions()->getShards(); $shards = $this->getSelectedShards(); - if (is_null($shards)) { + if (empty($shards)) { $shards = array_keys($allShards); } -- GitLab