From 643216dd6f255db96f227a86cea87026a1f5dd2c Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 31 Aug 2012 12:01:09 -0400
Subject: [PATCH] Replaced params property references with explicit getParams()
 calls.

---
 module/VuFind/src/VuFind/Search/Base/Results.php |  8 +++++---
 .../src/VuFind/Search/Favorites/Results.php      | 12 ++++++------
 .../src/VuFind/Search/MixedList/Results.php      |  2 +-
 module/VuFind/src/VuFind/Search/Solr/Results.php | 14 +++++++-------
 .../VuFind/Search/SolrAuthorFacets/Results.php   |  2 +-
 .../VuFind/src/VuFind/Search/Summon/Results.php  | 16 ++++++++--------
 6 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/module/VuFind/src/VuFind/Search/Base/Results.php b/module/VuFind/src/VuFind/Search/Base/Results.php
index cb7bddeaa2e..d050425a9cc 100644
--- a/module/VuFind/src/VuFind/Search/Base/Results.php
+++ b/module/VuFind/src/VuFind/Search/Base/Results.php
@@ -80,7 +80,9 @@ abstract class Results
      */
     public function __clone()
     {
-        $this->params = clone($this->params);
+        if (is_object($this->params)) {
+            $this->params = clone($this->params);
+        }
     }
 
     /**
@@ -148,7 +150,7 @@ abstract class Results
         $this->stopQueryTimer();
 
         // Process recommendations:
-        $recommendations = $this->params->getRecommendations(null);
+        $recommendations = $this->getParams()->getRecommendations(null);
         if (is_array($recommendations)) {
             foreach ($recommendations as $currentSet) {
                 foreach ($currentSet as $current) {
@@ -225,7 +227,7 @@ abstract class Results
     public function __call($methodName, $params)
     {
         // Proxy undefined methods to the parameter object:
-        $method = array($this->params, $methodName);
+        $method = array($this->getParams(), $methodName);
         if (!is_callable($method)) {
             throw new \Exception($methodName . ' cannot be called.');
         }
diff --git a/module/VuFind/src/VuFind/Search/Favorites/Results.php b/module/VuFind/src/VuFind/Search/Favorites/Results.php
index beaf8a034ac..3954b33c72f 100644
--- a/module/VuFind/src/VuFind/Search/Favorites/Results.php
+++ b/module/VuFind/src/VuFind/Search/Favorites/Results.php
@@ -64,7 +64,7 @@ class Results extends BaseResults
 
         // If there is no filter, we'll use all facets as the filter:
         if (is_null($filter)) {
-            $filter = $this->params->getFacetConfig();
+            $filter = $this->getParams()->getFacetConfig();
         }
 
         // Start building the facet list:
@@ -75,7 +75,7 @@ class Results extends BaseResults
         foreach ($validFields as $field) {
             if (!isset($this->facets[$field])) {
                 $this->facets[$field] = array(
-                    'label' => $this->params->getFacetLabel($field),
+                    'label' => $this->getParams()->getFacetLabel($field),
                     'list' => array()
                 );
                 switch ($field) {
@@ -87,7 +87,7 @@ class Results extends BaseResults
                             'displayText' => $list->title,
                             'count' => $list->cnt,
                             'isApplied' =>
-                                $this->params->hasFilter("$field:".$list->id)
+                                $this->getParams()->hasFilter("$field:".$list->id)
                         );
                     }
                     break;
@@ -103,7 +103,7 @@ class Results extends BaseResults
                             'displayText' => $tag->tag,
                             'count' => $tag->cnt,
                             'isApplied' =>
-                                $this->params->hasFilter("$field:".$tag->tag)
+                                $this->getParams()->hasFilter("$field:".$tag->tag)
                         );
                     }
                     break;
@@ -196,7 +196,7 @@ class Results extends BaseResults
      */
     protected function getTagFilters()
     {
-        $filters = $this->params->getFilters();
+        $filters = $this->getParams()->getFilters();
         return isset($filters['tags']) ? $filters['tags'] : array();
     }
 
@@ -212,7 +212,7 @@ class Results extends BaseResults
         if ($this->list === false) {
             // Check the filters for a list ID, and load the corresponding object
             // if one is found:
-            $filters = $this->params->getFilters();
+            $filters = $this->getParams()->getFilters();
             $listId = isset($filters['lists'][0]) ? $filters['lists'][0] : null;
             $this->list = is_null($listId)
                 ? null : UserListTable::getExisting($listId);
diff --git a/module/VuFind/src/VuFind/Search/MixedList/Results.php b/module/VuFind/src/VuFind/Search/MixedList/Results.php
index 3b82fb46517..31b252d11f2 100644
--- a/module/VuFind/src/VuFind/Search/MixedList/Results.php
+++ b/module/VuFind/src/VuFind/Search/MixedList/Results.php
@@ -61,7 +61,7 @@ class Results extends BaseResults
      */
     protected function performSearch()
     {
-        $recordsToRequest = $this->params->getRecordsToRequest();
+        $recordsToRequest = $this->getParams()->getRecordsToRequest();
         $this->results = Record::loadBatch($recordsToRequest);
         $this->resultTotal = count($this->results);
     }
diff --git a/module/VuFind/src/VuFind/Search/Solr/Results.php b/module/VuFind/src/VuFind/Search/Solr/Results.php
index 9d4b28f1330..ea92c9b6368 100644
--- a/module/VuFind/src/VuFind/Search/Solr/Results.php
+++ b/module/VuFind/src/VuFind/Search/Solr/Results.php
@@ -104,9 +104,9 @@ class Results extends BaseResults
             'sort' => $this->getSort() == 'relevance' ? null : $this->getSort(),
             'start' => $this->getStartRecord() - 1,
             'limit' => $this->getLimit(),
-            'facet' => $this->params->getFacetSettings(),
-            'filter' => $this->params->getFilterSettings(),
-            'spell' => $this->params->getSpellingQuery(),
+            'facet' => $this->getParams()->getFacetSettings(),
+            'filter' => $this->getParams()->getFilterSettings(),
+            'spell' => $this->getParams()->getSpellingQuery(),
             'dictionary' => $this->getOptions()->getSpellingDictionary(),
             'highlight' => $this->getOptions()->highlightEnabled()
         );
@@ -245,7 +245,7 @@ class Results extends BaseResults
 
         // Create a new search object
         $myClass = get_class($this);
-        $newParams = clone($this->params);
+        $newParams = clone($this->getParams());
         $newParams->getOptions()->useBasicDictionary();
 
         // Don't waste time loading facets or highlighting/retrieving results:
@@ -292,7 +292,7 @@ class Results extends BaseResults
     {
         $returnArray = array();
         $suggestions = $this->getRawSuggestions();
-        $tokens = $this->spellingTokens($this->params->getSpellingQuery());
+        $tokens = $this->spellingTokens($this->getParams()->getSpellingQuery());
 
         foreach ($suggestions as $term => $details) {
             // Find out if our suggestion is part of a token
@@ -395,7 +395,7 @@ class Results extends BaseResults
 
         // If there is no filter, we'll use all facets as the filter:
         if (is_null($filter)) {
-            $filter = $this->params->getFacetConfig();
+            $filter = $this->getParams()->getFacetConfig();
         }
 
         // Start building the facet list:
@@ -433,7 +433,7 @@ class Results extends BaseResults
                     = $translate ? Translator::translate($facet[0]) : $facet[0];
                 $currentSettings['count'] = $facet[1];
                 $currentSettings['isApplied']
-                    = $this->params->hasFilter("$field:".$facet[0]);
+                    = $this->getParams()->hasFilter("$field:".$facet[0]);
 
                 // Store the collected values:
                 $list[$field]['list'][] = $currentSettings;
diff --git a/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Results.php b/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Results.php
index 4054b6ca47d..57c44513f80 100644
--- a/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Results.php
+++ b/module/VuFind/src/VuFind/Search/SolrAuthorFacets/Results.php
@@ -55,7 +55,7 @@ class Results extends SolrResults
             'query' => $solr->buildQuery($this->getSearchTerms()),
             'handler' => $this->getSearchHandler(),
             'limit' => 0,
-            'facet' => $this->params->getFacetSettings(),
+            'facet' => $this->getParams()->getFacetSettings(),
         );
 
         // Perform the search:
diff --git a/module/VuFind/src/VuFind/Search/Summon/Results.php b/module/VuFind/src/VuFind/Search/Summon/Results.php
index 7b01cebd223..8b71d56d479 100644
--- a/module/VuFind/src/VuFind/Search/Summon/Results.php
+++ b/module/VuFind/src/VuFind/Search/Summon/Results.php
@@ -75,7 +75,7 @@ class Results extends BaseResults
     {
         // The "relevance" sort option is a VuFind reserved word; we need to make
         // this null in order to achieve the desired effect with Summon:
-        $sort = $this->params->getSort();
+        $sort = $this->getParams()->getSort();
         $finalSort = ($sort == 'relevance') ? null : $sort;
 
         // Perform the actual search
@@ -84,8 +84,8 @@ class Results extends BaseResults
             $summon->buildQuery($this->getSearchTerms()),
             array(
                 'sort' => $finalSort,
-                'pageNumber' => $this->params->getPage(),
-                'pageSize' => $this->params->getLimit(),
+                'pageNumber' => $this->getParams()->getPage(),
+                'pageSize' => $this->getParams()->getLimit(),
                 'didYouMean' => $this->getOptions()->spellcheckEnabled()
             )
         );
@@ -94,13 +94,13 @@ class Results extends BaseResults
             $query->setHighlightStart('{{{{START_HILITE}}}}');
             $query->setHighlightEnd('{{{{END_HILITE}}}}');
         }
-        $query->initFacets($this->params->getFullFacetSettings());
-        $query->initFilters($this->params->getFilterList());
+        $query->initFacets($this->getParams()->getFullFacetSettings());
+        $query->initFilters($this->getParams()->getFilterList());
         $this->rawResponse = $summon->query($query);
 
         // Add fake date facets if flagged earlier; this is necessary in order
         // to display the date range facet control in the interface.
-        $dateFacets = $this->params->getDateFacetSettings();
+        $dateFacets = $this->getParams()->getDateFacetSettings();
         if (!empty($dateFacets)) {
             if (!isset($this->rawResponse['facetFields'])) {
                 $this->rawResponse['facetFields'] = array();
@@ -174,7 +174,7 @@ class Results extends BaseResults
     {
         // If there is no filter, we'll use all facets as the filter:
         if (is_null($filter)) {
-            $filter = $this->params->getFacetConfig();
+            $filter = $this->getParams()->getFacetConfig();
         } else {
             // If there is a filter, make sure the field names are properly
             // stripped of extra parameters:
@@ -201,7 +201,7 @@ class Results extends BaseResults
             && is_array($this->rawResponse['facetFields'])
         ) {
             // Get the filter list -- we'll need to check it below:
-            $filterList = $this->params->getFilters();
+            $filterList = $this->getParams()->getFilters();
 
             foreach ($this->rawResponse['facetFields'] as $current) {
                 // The "displayName" value is actually the name of the field on
-- 
GitLab