From 5fb285d74afae4f9cb7d199ffc34bcea3b66a0ba Mon Sep 17 00:00:00 2001 From: Frank Morgner <morgnerf@ub.uni-leipzig.de> Date: Mon, 28 Nov 2016 10:05:29 +0100 Subject: [PATCH] refs #9191 bugfixing Ebsco module * remove false modifier at regex * catch void variables to prevent notices --- .../finc/src/finc/Recommend/EbscoResults.php | 23 +++++++++---------- .../templates/Recommend/EbscoResults.phtml | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/module/finc/src/finc/Recommend/EbscoResults.php b/module/finc/src/finc/Recommend/EbscoResults.php index 946ed640161..2e4fa1a6253 100644 --- a/module/finc/src/finc/Recommend/EbscoResults.php +++ b/module/finc/src/finc/Recommend/EbscoResults.php @@ -111,7 +111,7 @@ class EbscoResults implements \VuFind\Recommend\RecommendInterface, { // Parse out parameters: $params = explode(':', $settings); - if (!isset($params[0]) || (0 < preg_match('/\s/g', $params[0]))) { + if (!isset($params[0]) || (0 < preg_match('/\s/', $params[0]))) { throw new Exception( 'Isil as namespace for service has not been set yet or is false.' ); @@ -219,24 +219,23 @@ class EbscoResults implements \VuFind\Recommend\RecommendInterface, * Sort databases by hits * * @param array $results Unprocessed array of curl requrest. - * @param string $sortOrder Order of sort. Default: "SORT_DESC" + * @param string $sortOrder Order of sort. Default: SORT_DESC * * @return array $results * @access protected */ protected function sortByHits($results, $sortOrder = SORT_DESC) { - if (!is_array($results) && count($results['results']) == 0) { - return $results['results'] = []; + if (isset($results['results']) && count($results['results']) > 0) { + $databases = $results['results']; + foreach ($databases as $key => $row) { + $hits[$key] = $row['hits']; + } + array_multisort($hits, $sortOrder, $databases); + $results['results'] = $databases; + } else { + $results['results'] = []; } - - $databases = $results['results']; - foreach ($databases as $key => $row) { - $hits[$key] = $row['hits']; - } - array_multisort($hits, $sortOrder, $databases); - $results['results'] = $databases; - return $results; } diff --git a/themes/finc/templates/Recommend/EbscoResults.phtml b/themes/finc/templates/Recommend/EbscoResults.phtml index 43b06a82e18..303353c4725 100644 --- a/themes/finc/templates/Recommend/EbscoResults.phtml +++ b/themes/finc/templates/Recommend/EbscoResults.phtml @@ -1,6 +1,6 @@ <? $data = $this->recommend->getResult(); -if (is_array($data) && count($data['results']) > 0): ?> +if (is_array($data['results']) && count($data['results']) > 0): ?> <ul id="side-panel-ebsco" class="accordion" data-accordion=""> <li class="accordion-navigation active"> <a class="title" href="#side-collapse-ebsco" aria-expanded="true"> -- GitLab