From d3dfb69c84968c2283e05f0caff14de9132e4e90 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 31 Aug 2012 11:35:58 -0400
Subject: [PATCH] Eliminated __call() method in \VuFind\Search\Base\Options;
 replaced with explicit getOptions() calls to make the code more consistent
 and understandable.

---
 .../VuFind/src/VuFind/Autocomplete/Solr.php   |   2 +-
 .../src/VuFind/Autocomplete/SolrReserves.php  |   2 +-
 .../src/VuFind/Controller/AbstractSearch.php  |   7 +-
 .../Controller/Plugin/ResultScroller.php      |   2 +-
 module/VuFind/src/VuFind/OAI/Server.php       |   4 +-
 .../VuFind/Recommend/AuthorityRecommend.php   |   2 +-
 .../VuFind/src/VuFind/Search/Base/Params.php  | 105 ++++++++++--------
 .../VuFind/src/VuFind/Search/Base/Results.php |  36 +++++-
 .../VuFind/src/VuFind/Search/Solr/Params.php  |  14 +--
 .../VuFind/src/VuFind/Search/Solr/Results.php |  24 ++--
 .../src/VuFind/Search/SolrAuthor/Params.php   |   2 +-
 .../src/VuFind/Search/Summon/Results.php      |   8 +-
 module/VuFind/src/VuFind/Search/UrlHelper.php |  16 ++-
 .../Theme/Root/Helper/SortFacetList.php       |   3 +-
 .../Recommend/AuthorityRecommend.phtml        |   2 +-
 .../templates/Recommend/CatalogResults.phtml  |   2 +-
 .../templates/Recommend/SummonResults.phtml   |   2 +-
 .../templates/search/history-table.phtml      |   2 +-
 .../templates/search/history-table.phtml      |   2 +-
 19 files changed, 145 insertions(+), 92 deletions(-)

diff --git a/module/VuFind/src/VuFind/Autocomplete/Solr.php b/module/VuFind/src/VuFind/Autocomplete/Solr.php
index 11ddae09040..f7a7285e0c6 100644
--- a/module/VuFind/src/VuFind/Autocomplete/Solr.php
+++ b/module/VuFind/src/VuFind/Autocomplete/Solr.php
@@ -90,7 +90,7 @@ class Solr implements AutocompleteInterface
         // Build a new search object:
         $params = new \VuFind\Search\Solr\Params();
         $this->searchObject = new \VuFind\Search\Solr\Results($params);
-        $this->searchObject->spellcheckEnabled(false);
+        $this->searchObject->getOptions()->spellcheckEnabled(false);
     }
 
     /**
diff --git a/module/VuFind/src/VuFind/Autocomplete/SolrReserves.php b/module/VuFind/src/VuFind/Autocomplete/SolrReserves.php
index c933f1fb116..caf15fdff8c 100644
--- a/module/VuFind/src/VuFind/Autocomplete/SolrReserves.php
+++ b/module/VuFind/src/VuFind/Autocomplete/SolrReserves.php
@@ -68,6 +68,6 @@ class SolrReserves extends Solr
         // Build a new search object:
         $params = new \VuFind\Search\SolrReserves\Params();
         $this->searchObject = new \VuFind\Search\SolrReserves\Results($params);
-        $this->searchObject->spellcheckEnabled(false);
+        $this->searchObject->getOptions()->spellcheckEnabled(false);
     }
 }
diff --git a/module/VuFind/src/VuFind/Controller/AbstractSearch.php b/module/VuFind/src/VuFind/Controller/AbstractSearch.php
index 2c38659e06e..2f90c581658 100644
--- a/module/VuFind/src/VuFind/Controller/AbstractSearch.php
+++ b/module/VuFind/src/VuFind/Controller/AbstractSearch.php
@@ -120,7 +120,7 @@ class AbstractSearch extends AbstractBase
             // object, and it also prevents the user from ever landing on a
             // "?saved=xxxx" URL, which may not persist beyond the current session.
             // (We want all searches to be persistent and bookmarkable).
-            $details = $savedSearch->getSearchAction();
+            $details = $savedSearch->getOptions()->getSearchAction();
             $url = $this->url()->fromRoute($details);
             $url .= $savedSearch->getUrl()->getParams(false);
             return $this->redirect()->toUrl($url);
@@ -179,8 +179,9 @@ class AbstractSearch extends AbstractBase
             // search.
             $view->results = $results;
             if ($this->rememberSearch) {
-                $searchUrl = $this->url()->fromRoute($results->getSearchAction())
-                    . $results->getUrl()->getParams(false);
+                $searchUrl = $this->url()->fromRoute(
+                    $results->getOptions()->getSearchAction()
+                ) . $results->getUrl()->getParams(false);
                 Memory::rememberSearch($searchUrl);
             }
 
diff --git a/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php b/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php
index 88f1aa79c3e..99256e76d4a 100644
--- a/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php
+++ b/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php
@@ -349,7 +349,7 @@ class ResultScroller extends AbstractPlugin
     protected function rememberSearch($search)
     {
         $baseUrl = $this->getController()->url()->fromRoute(
-            $search->getSearchAction()
+            $search->getOptions()->getSearchAction()
         );
         Memory::rememberSearch(
             $baseUrl . $search->getUrl()->getParams(false)
diff --git a/module/VuFind/src/VuFind/OAI/Server.php b/module/VuFind/src/VuFind/OAI/Server.php
index 73e2601bc66..a3346639811 100644
--- a/module/VuFind/src/VuFind/OAI/Server.php
+++ b/module/VuFind/src/VuFind/OAI/Server.php
@@ -560,8 +560,8 @@ class Server
         $paramsClass = 'VuFind\Search\\' . $this->searchClassId . '\Params';
         $params = new $paramsClass();
         $params->setLimit($limit);
-        $params->disableHighlighting();
-        $params->spellcheckEnabled(false);
+        $params->getOptions()->disableHighlighting();
+        $params->getOptions()->spellcheckEnabled(false);
         $params->setSort('last_indexed asc', true);
 
         // Construct a range query based on last indexed time:
diff --git a/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php b/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php
index 65e39e52aba..27b4f2dc322 100644
--- a/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php
+++ b/module/VuFind/src/VuFind/Recommend/AuthorityRecommend.php
@@ -135,7 +135,7 @@ class AuthorityRecommend implements RecommendInterface
             $authParams = new SolrAuthParams();
             $authParams->initFromRequest($request);
             foreach ($this->filters as $filter) {
-                $authParams->addHiddenFilter($filter);
+                $authParams->getOptions()->addHiddenFilter($filter);
             }
             $authResults = new SolrAuthResults($authParams);
             $results = $authResults->getResults();
diff --git a/module/VuFind/src/VuFind/Search/Base/Params.php b/module/VuFind/src/VuFind/Search/Base/Params.php
index 82a9dfc2218..fd4e97d80a6 100644
--- a/module/VuFind/src/VuFind/Search/Base/Params.php
+++ b/module/VuFind/src/VuFind/Search/Base/Params.php
@@ -74,55 +74,62 @@ class Params
      */
     public function __construct($options = null)
     {
-        if (is_null($options)) {
+        if (null !== $options) {
+            $this->setOptions($options);
+        }
+    }
+
+    /**
+     * Get the search options object.
+     *
+     * @return \VuFind\Search\Base\Options
+     */
+    public function getOptions()
+    {
+        // If no options have been set, use defaults:
+        if (null === $this->options) {
             // Create a copy of the default configuration:
             $this->options = clone(
                 SearchOptions::getInstance($this->getSearchClassId())
             );
-        } else {
-            $this->options = $options;
         }
+        return $this->options;
     }
 
     /**
-     * Copy constructor
+     * Set the search options object.
+     *
+     * @param \VuFind\Search\Base\Options $options Options to use
      *
      * @return void
      */
-    public function __clone()
+    public function setOptions(Options $options)
     {
-        $this->options = clone($this->options);
+        $this->options = $options;
     }
 
     /**
-     * Get the identifier used for naming the various search classes in this family.
+     * Copy constructor
      *
-     * @return string
+     * @return void
      */
-    public function getSearchClassId()
+    public function __clone()
     {
-        return SearchOptions::extractSearchClassId(get_class($this));
+        if (is_object($this->options)) {
+            $this->options = clone($this->options);
+        }
     }
 
     /**
-     * External method caller (proxies unrecognized methods to options object)
-     *
-     * @param string $methodName Name of function trying to be called
-     * @param Array  $params     Parameters to be sent to the function
+     * Get the identifier used for naming the various search classes in this family.
      *
-     * @return mixed
+     * @return string
      */
-    public function __call($methodName, $params)
+    public function getSearchClassId()
     {
-        // Proxy undefined methods to the options object:
-        $method = array($this->options, $methodName);
-        if (!is_callable($method)) {
-            throw new \Exception($methodName . ' cannot be called.');
-        }
-        return call_user_func_array($method, $params);
+        return SearchOptions::extractSearchClassId(get_class($this));
     }
 
-
     /**
      * Pull the search parameters
      *
@@ -152,8 +159,8 @@ class Params
         // Remember the user's settings for future reference (we only want to do
         // this in initFromRequest, since other code may call the set methods from
         // other contexts!):
-        $this->rememberLastLimit($this->getLimit());
-        $this->rememberLastSort($this->getSort());
+        $this->getOptions()->rememberLastLimit($this->getLimit());
+        $this->getOptions()->rememberLastSort($this->getSort());
     }
 
     /**
@@ -166,7 +173,7 @@ class Params
      */
     protected function initShards($request)
     {
-        $legalShards = array_keys($this->options->getShards());
+        $legalShards = array_keys($this->getOptions()->getShards());
         $requestShards = $request->get('shard', array());
         if (!is_array($requestShards)) {
             $requestShards = array($requestShards);
@@ -183,7 +190,7 @@ class Params
         // If we got this far and still have no selections established, revert to
         // defaults:
         if (empty($this->selectedShards)) {
-            $this->selectedShards = $this->options->getDefaultSelectedShards();
+            $this->selectedShards = $this->getOptions()->getDefaultSelectedShards();
         }
     }
 
@@ -198,10 +205,10 @@ class Params
     protected function initLimit($request)
     {
         // Check for a limit parameter in the url.
-        $defaultLimit = $this->options->getDefaultLimit();
+        $defaultLimit = $this->getOptions()->getDefaultLimit();
         if (($limit = $request->get('limit')) != $defaultLimit) {
             // make sure the url parameter is a valid limit
-            if (in_array($limit, $this->options->getLimitOptions())) {
+            if (in_array($limit, $this->getOptions()->getLimitOptions())) {
                 $this->limit = $limit;
                 return;
             }
@@ -306,7 +313,7 @@ class Params
         $this->searchType = 'basic';
 
         if (empty($handler)) {
-            $handler = $this->options->getDefaultHandler();
+            $handler = $this->getOptions()->getDefaultHandler();
         }
 
         $this->searchTerms = array(
@@ -344,7 +351,7 @@ class Params
                     if (isset($typeArr[$i]) && !empty($typeArr[$i])) {
                         $handler = $typeArr[$i];
                     } else {
-                        $handler = $this->options->getDefaultHandler();
+                        $handler = $this->getOptions()->getDefaultHandler();
                     }
 
                     // Add term to this group
@@ -400,20 +407,20 @@ class Params
     {
         // Check for a view parameter in the url.
         $view = $request->get('view');
-        $lastView = $this->getLastView();
+        $lastView = $this->getOptions()->getLastView();
         if (!empty($view)) {
             if ($view == 'rss') {
                 // we don't want to store rss in the Session
                 $this->setView('rss');
             } else {
                 // store non-rss views in Session for persistence
-                $validViews = $this->getViewOptions();
+                $validViews = $this->getOptions()->getViewOptions();
                 // make sure the url parameter is a valid view
                 if (in_array($view, array_keys($validViews))) {
                     $this->setView($view);
-                    $this->rememberLastView($view);
+                    $this->getOptions()->rememberLastView($view);
                 } else {
-                    $this->setView($this->getDefaultView());
+                    $this->setView($this->getOptions()->getDefaultView());
                 }
             }
         } else if (!empty($lastView)) {
@@ -421,7 +428,7 @@ class Params
             $this->setView($lastView);
         } else {
             // otherwise load the default
-            $this->setView($this->getDefaultView());
+            $this->setView($this->getOptions()->getDefaultView());
         }
     }
 
@@ -432,7 +439,8 @@ class Params
      */
     public function getDefaultSort()
     {
-        return $this->getDefaultSortByHandler($this->getSearchHandler());
+        return $this->getOptions()
+            ->getDefaultSortByHandler($this->getSearchHandler());
     }
 
     /**
@@ -507,7 +515,7 @@ class Params
         }
 
         // Validate and assign the sort value:
-        $valid = array_keys($this->getSortOptions());
+        $valid = array_keys($this->getOptions()->getSortOptions());
         if (!empty($sort) && in_array($sort, $valid)) {
             $this->sort = $sort;
         } else {
@@ -516,7 +524,7 @@ class Params
 
         // In RSS mode, we may want to adjust sort settings:
         if (!$this->skipRssSort && $this->getView() == 'rss') {
-            $this->sort = $this->getRssSort($this->sort);
+            $this->sort = $this->getOptions()->getRssSort($this->sort);
         }
     }
 
@@ -564,7 +572,8 @@ class Params
      */
     public function getView()
     {
-        return is_null($this->view) ? $this->getDefaultView() : $this->view;
+        return is_null($this->view)
+            ? $this->getOptions()->getDefaultView() : $this->view;
     }
 
     /**
@@ -598,8 +607,9 @@ class Params
             if (isset($search['group'])) {
                 foreach ($search['group'] as $group) {
                     // Build this group individually as a basic search
-                    $thisGroup[] = $this->getHumanReadableFieldName($group['field'])
-                        . ":{$group['lookfor']}";
+                    $thisGroup[] = $this->getOptions()->getHumanReadableFieldName(
+                        $group['field']
+                    ) . ":{$group['lookfor']}";
                 }
             }
             // Is this an exclusion (NOT) group or a normal group?
@@ -709,7 +719,8 @@ class Params
 
         // Load the necessary settings to determine the appropriate recommendations
         // module:
-        $searchSettings = ConfigReader::getConfig($this->getSearchIni());
+        $searchSettings
+            = ConfigReader::getConfig($this->getOptions()->getSearchIni());
 
         // If we have a search type set, save it so we can try to load a
         // type-specific recommendations module:
@@ -1032,7 +1043,7 @@ class Params
         // Loop through all the current filter fields
         foreach ($this->filterList as $field => $values) {
             // and each value currently used for that field
-            $translate = in_array($field, $this->getTranslatedFacets());
+            $translate = in_array($field, $this->getOptions()->getTranslatedFacets());
             foreach ($values as $value) {
                 // Add to the list unless it's in the list of fields to skip:
                 if (!isset($skipList[$field])
@@ -1313,7 +1324,7 @@ class Params
     public function getViewList()
     {
         $list = array();
-        foreach ($this->getViewOptions() as $key => $value) {
+        foreach ($this->getOptions()->getViewOptions() as $key => $value) {
             $list[$key] = array(
                 'desc' => $value,
                 'selected' => ($key == $this->getView())
@@ -1331,7 +1342,7 @@ class Params
     public function getLimitList()
     {
         // Loop through all the current limits
-        $valid = $this->getLimitOptions();
+        $valid = $this->getOptions()->getLimitOptions();
         $list = array();
         foreach ($valid as $limit) {
             $list[$limit] = array(
@@ -1351,7 +1362,7 @@ class Params
     public function getSortList()
     {
         // Loop through all the current filter fields
-        $valid = $this->getSortOptions();
+        $valid = $this->getOptions()->getSortOptions();
         $list = array();
         foreach ($valid as $sort => $desc) {
             $list[$sort] = array(
diff --git a/module/VuFind/src/VuFind/Search/Base/Results.php b/module/VuFind/src/VuFind/Search/Base/Results.php
index 562f776036d..cb7bddeaa2e 100644
--- a/module/VuFind/src/VuFind/Search/Base/Results.php
+++ b/module/VuFind/src/VuFind/Search/Base/Results.php
@@ -70,7 +70,7 @@ abstract class Results
     public function __construct(Params $params)
     {
         // Save the parameters, then perform the search:
-        $this->params = $params;
+        $this->setParams($params);
     }
 
     /**
@@ -83,6 +83,38 @@ abstract class Results
         $this->params = clone($this->params);
     }
 
+    /**
+     * Get the search parameters object.
+     *
+     * @return \VuFind\Search\Base\Params
+     */
+    public function getParams()
+    {
+        return $this->params;
+    }
+
+    /**
+     * Set the search parameters object.
+     *
+     * @param \VuFind\Search\Base\Params $params Parameters to set
+     *
+     * @return void
+     */
+    public function setParams($params)
+    {
+        $this->params = $params;
+    }
+
+    /**
+     * Get the search options object.
+     *
+     * @return \VuFind\Search\Base\Options
+     */
+    public function getOptions()
+    {
+        return $this->getParams()->getOptions();
+    }
+
     /**
      * Get the URL helper for this object.
      *
@@ -385,7 +417,7 @@ abstract class Results
     {
         // If there is a limit on how many pages are accessible,
         // apply that limit now:
-        $max = $this->getVisibleSearchResultLimit();
+        $max = $this->getOptions()->getVisibleSearchResultLimit();
         $total = $this->getResultTotal();
         if ($max > 0 && $total > $max) {
             $total = $max;
diff --git a/module/VuFind/src/VuFind/Search/Solr/Params.php b/module/VuFind/src/VuFind/Search/Solr/Params.php
index f200359e670..844e091a670 100644
--- a/module/VuFind/src/VuFind/Search/Solr/Params.php
+++ b/module/VuFind/src/VuFind/Search/Solr/Params.php
@@ -98,7 +98,7 @@ class Params extends BaseParams
     public function getFilterSettings()
     {
         // Define Filter Query
-        $filterQuery = $this->getHiddenFilters();
+        $filterQuery = $this->getOptions()->getHiddenFilters();
         foreach ($this->filterList as $field => $filter) {
             foreach ($filter as $value) {
                 // Special case -- allow trailing wildcards and ranges:
@@ -300,15 +300,15 @@ class Params extends BaseParams
     public function getSpellingQuery()
     {
         // Build our spellcheck query
-        if ($this->options->spellcheckEnabled()) {
-            if ($this->options->usesSimpleSpelling()) {
-                $this->options->useBasicDictionary();
+        if ($this->getOptions()->spellcheckEnabled()) {
+            if ($this->getOptions()->usesSimpleSpelling()) {
+                $this->getOptions()->useBasicDictionary();
             }
             $spellcheck = $this->buildSpellingQuery();
 
             // If the spellcheck query is purely numeric, skip it if
             // the appropriate setting is turned on.
-            if ($this->options->shouldSkipNumericSpelling()
+            if ($this->getOptions()->shouldSkipNumericSpelling()
                 && is_numeric($spellcheck)
             ) {
                 return '';
@@ -368,7 +368,7 @@ class Params extends BaseParams
         $hidden = $request->get('hiddenFilters');
         if (!empty($hidden) && is_array($hidden)) {
             foreach ($hidden as $current) {
-                $this->addHiddenFilter($current);
+                $this->getOptions()->addHiddenFilter($current);
             }
         }
     }
@@ -384,7 +384,7 @@ class Params extends BaseParams
     public function setQueryIDs($ids)
     {
         // No need for spell checking on an ID query!
-        $this->options->spellcheckEnabled(false);
+        $this->getOptions()->spellcheckEnabled(false);
 
         // Special case -- no IDs to set:
         if (empty($ids)) {
diff --git a/module/VuFind/src/VuFind/Search/Solr/Results.php b/module/VuFind/src/VuFind/Search/Solr/Results.php
index ecd9fe3ac11..9d4b28f1330 100644
--- a/module/VuFind/src/VuFind/Search/Solr/Results.php
+++ b/module/VuFind/src/VuFind/Search/Solr/Results.php
@@ -107,8 +107,8 @@ class Results extends BaseResults
             'facet' => $this->params->getFacetSettings(),
             'filter' => $this->params->getFilterSettings(),
             'spell' => $this->params->getSpellingQuery(),
-            'dictionary' => $this->getSpellingDictionary(),
-            'highlight' => $this->highlightEnabled()
+            'dictionary' => $this->getOptions()->getSpellingDictionary(),
+            'highlight' => $this->getOptions()->highlightEnabled()
         );
 
         // Perform the search:
@@ -119,11 +119,11 @@ class Results extends BaseResults
             ? $this->rawResponse['response']['numFound'] : 0;
 
         // Process spelling suggestions if no index error resulted from the query
-        if ($this->spellcheckEnabled()) {
+        if ($this->getOptions()->spellcheckEnabled()) {
             // Shingle dictionary
             $this->processSpelling();
             // Make sure we don't endlessly loop
-            if ($this->getSpellingDictionary() == 'default') {
+            if ($this->getOptions()->getSpellingDictionary() == 'default') {
                 // Expand against the basic dictionary
                 $this->basicSpelling();
             }
@@ -158,7 +158,9 @@ class Results extends BaseResults
             $ourTerm = $suggestion[0];
 
             // Skip numeric terms if numeric suggestions are disabled
-            if ($this->shouldSkipNumericSpelling() && is_numeric($ourTerm)) {
+            if ($this->getOptions()->shouldSkipNumericSpelling()
+                && is_numeric($ourTerm)
+            ) {
                 continue;
             }
 
@@ -184,9 +186,9 @@ class Results extends BaseResults
             // Make sure it has suggestions and is valid
             if (count($newList) > 0 && $validTerm) {
                 // Did we get more suggestions then our limit?
-                if ($count > $this->getSpellingLimit()) {
+                if ($count > $this->getOptions()->getSpellingLimit()) {
                     // Cut the list at the limit
-                    array_splice($newList, $this->getSpellingLimit());
+                    array_splice($newList, $this->getOptions()->getSpellingLimit());
                 }
                 $suggestionList[$ourTerm]['freq'] = $ourHit;
                 // Format the list nicely
@@ -244,11 +246,11 @@ class Results extends BaseResults
         // Create a new search object
         $myClass = get_class($this);
         $newParams = clone($this->params);
-        $newParams->useBasicDictionary();
+        $newParams->getOptions()->useBasicDictionary();
 
         // Don't waste time loading facets or highlighting/retrieving results:
         $newParams->resetFacetConfig();
-        $newParams->disableHighlighting();
+        $newParams->getOptions()->disableHighlighting();
         $newParams->setLimit(0);
         $newParams->recommendationsEnabled(false);
 
@@ -421,7 +423,7 @@ class Results extends BaseResults
             // Build our array of values for this field
             $list[$field]['list']  = array();
             // Should we translate values for the current facet?
-            $translate = in_array($field, $this->params->getTranslatedFacets());
+            $translate = in_array($field, $this->getOptions()->getTranslatedFacets());
             // Loop through values:
             foreach ($data as $facet) {
                 // Initialize the array of data about the current facet:
@@ -509,7 +511,7 @@ class Results extends BaseResults
     public function getSimilarRecords($id)
     {
         $solr = static::getSolrConnection($this->getSelectedShards());
-        $filters = $this->getHiddenFilters();
+        $filters = $this->getOptions()->getHiddenFilters();
         $extras = empty($filters) ? array() : array('fq' => $filters);
         $rawResponse = $solr->getMoreLikeThis($id, $extras);
         $results = array();
diff --git a/module/VuFind/src/VuFind/Search/SolrAuthor/Params.php b/module/VuFind/src/VuFind/Search/SolrAuthor/Params.php
index 77ba4c375f7..fb5f9f4af16 100644
--- a/module/VuFind/src/VuFind/Search/SolrAuthor/Params.php
+++ b/module/VuFind/src/VuFind/Search/SolrAuthor/Params.php
@@ -89,7 +89,7 @@ class Params extends SolrParams
     {
         // Load the necessary settings to determine the appropriate recommendations
         // module:
-        $ss = ConfigReader::getConfig($this->getSearchIni());
+        $ss = ConfigReader::getConfig($this->getOptions()->getSearchIni());
 
         // Load the AuthorModuleRecommendations configuration if available, use
         // standard defaults otherwise:
diff --git a/module/VuFind/src/VuFind/Search/Summon/Results.php b/module/VuFind/src/VuFind/Search/Summon/Results.php
index 89fd85cc3d2..7b01cebd223 100644
--- a/module/VuFind/src/VuFind/Search/Summon/Results.php
+++ b/module/VuFind/src/VuFind/Search/Summon/Results.php
@@ -86,10 +86,10 @@ class Results extends BaseResults
                 'sort' => $finalSort,
                 'pageNumber' => $this->params->getPage(),
                 'pageSize' => $this->params->getLimit(),
-                'didYouMean' => $this->spellcheckEnabled()
+                'didYouMean' => $this->getOptions()->spellcheckEnabled()
             )
         );
-        if ($this->highlightEnabled()) {
+        if ($this->getOptions()->highlightEnabled()) {
             $query->setHighlight(true);
             $query->setHighlightStart('{{{{START_HILITE}}}}');
             $query->setHighlightEnd('{{{{END_HILITE}}}}');
@@ -115,7 +115,7 @@ class Results extends BaseResults
         }
 
         // Save spelling details if they exist.
-        if ($this->spellcheckEnabled()) {
+        if ($this->getOptions()->spellcheckEnabled()) {
             $this->processSpelling();
         }
 
@@ -213,7 +213,7 @@ class Results extends BaseResults
                 if (isset($filter[$field])) {
                     // Should we translate values for the current facet?
                     $translate
-                        = in_array($field, $this->params->getTranslatedFacets());
+                        = in_array($field, $this->getOptions()->getTranslatedFacets());
 
                     // Loop through all the facet values to see if any are applied.
                     foreach ($current['counts'] as $facetIndex => $facetDetails) {
diff --git a/module/VuFind/src/VuFind/Search/UrlHelper.php b/module/VuFind/src/VuFind/Search/UrlHelper.php
index 94482cf5ccd..f0742f809d7 100644
--- a/module/VuFind/src/VuFind/Search/UrlHelper.php
+++ b/module/VuFind/src/VuFind/Search/UrlHelper.php
@@ -122,11 +122,15 @@ class UrlHelper
             $params['sort'] = $sort;
         }
         $limit = $this->results->getLimit();
-        if (!is_null($limit) && $limit != $this->results->getDefaultLimit()) {
+        if (!is_null($limit)
+            && $limit != $this->results->getOptions()->getDefaultLimit()
+        ) {
             $params['limit'] = $limit;
         }
         $view = $this->results->getView();
-        if (!is_null($view) && $view != $this->results->getDefaultView()) {
+        if (!is_null($view)
+            && $view != $this->results->getOptions()->getDefaultView()
+        ) {
             $params['view'] = $view;
         }
         if ($this->results->getPage() != 1) {
@@ -145,7 +149,8 @@ class UrlHelper
         if (!empty($shards)) {
             sort($shards);
             $key = implode(':::', $shards);
-            $defaultShards = $this->results->getDefaultSelectedShards();
+            $defaultShards
+                = $this->results->getOptions()->getDefaultSelectedShards();
             sort($defaultShards);
             if (implode(':::', $shards) != implode(':::', $defaultShards)) {
                 $params['shard'] = $shards;
@@ -313,7 +318,8 @@ class UrlHelper
     public function setHandler($handler, $escape = true)
     {
         return $this->updateQueryString(
-            'type', $handler, $this->results->getDefaultHandler(), $escape
+            'type', $handler, $this->results->getOptions()->getDefaultHandler(),
+            $escape
         );
     }
 
@@ -349,7 +355,7 @@ class UrlHelper
     public function setLimit($l, $escape = true)
     {
         return $this->updateQueryString(
-            'limit', $l, $this->results->getDefaultLimit(), $escape
+            'limit', $l, $this->results->getOptions()->getDefaultLimit(), $escape
         );
     }
 
diff --git a/module/VuFind/src/VuFind/Theme/Root/Helper/SortFacetList.php b/module/VuFind/src/VuFind/Theme/Root/Helper/SortFacetList.php
index 3fd15225911..18d8b00ee21 100644
--- a/module/VuFind/src/VuFind/Theme/Root/Helper/SortFacetList.php
+++ b/module/VuFind/src/VuFind/Theme/Root/Helper/SortFacetList.php
@@ -55,7 +55,8 @@ class SortFacetList extends AbstractHelper
     public function __invoke($results, $field, $list, $searchRoute)
     {
         $facets = array();
-        $results->setLimit($results->getDefaultLimit());    // avoid limit on URL
+        // avoid limit on URL
+        $results->setLimit($results->getOptions()->getDefaultLimit());
         $urlHelper = $this->getView()->plugin('url');
         foreach ($list as $value) {
             $url = $urlHelper($searchRoute)
diff --git a/themes/blueprint/templates/Recommend/AuthorityRecommend.phtml b/themes/blueprint/templates/Recommend/AuthorityRecommend.phtml
index f196b95b48c..6697ae2ee40 100644
--- a/themes/blueprint/templates/Recommend/AuthorityRecommend.phtml
+++ b/themes/blueprint/templates/Recommend/AuthorityRecommend.phtml
@@ -5,7 +5,7 @@
       <? for ($i = 0; $i < count($data); $i++): ?>
         <?
             // Generate a new search URL that replaces the user's current term with the authority term:
-            $url = $this->url($this->results->getSearchAction())
+            $url = $this->url($this->results->getOptions()->getSearchAction())
                 . $this->results->getUrl()->replaceTerm($this->results->getDisplayQuery(), $data[$i]['heading']);
         ?>
         <a href="<?=$url?>"><?=$this->escapeHtml($data[$i]['heading'])?></a><? if ($i != count($data) - 1): ?>, <? endif; ?>
diff --git a/themes/blueprint/templates/Recommend/CatalogResults.phtml b/themes/blueprint/templates/Recommend/CatalogResults.phtml
index ae8699a4101..e4078e47953 100644
--- a/themes/blueprint/templates/Recommend/CatalogResults.phtml
+++ b/themes/blueprint/templates/Recommend/CatalogResults.phtml
@@ -35,6 +35,6 @@
     </li>
     <? endforeach; ?>
   </ul>
-  <p><a href="<?=$this->url($searchObject->getSearchAction()) . $searchObject->getUrl()->setLimit($searchObject->getDefaultLimit())?>"><?=$this->transEsc('More catalog results')?>...</a></p>
+  <p><a href="<?=$this->url($searchObject->getOptions()->getSearchAction()) . $searchObject->getUrl()->setLimit($searchObject->getOptions()->getDefaultLimit())?>"><?=$this->transEsc('More catalog results')?>...</a></p>
 </div>
 <? endif ?>
\ No newline at end of file
diff --git a/themes/blueprint/templates/Recommend/SummonResults.phtml b/themes/blueprint/templates/Recommend/SummonResults.phtml
index 00ec99285ed..cd9df8c9197 100644
--- a/themes/blueprint/templates/Recommend/SummonResults.phtml
+++ b/themes/blueprint/templates/Recommend/SummonResults.phtml
@@ -34,6 +34,6 @@
     </li>
     <? endforeach; ?>
   </ul>
-  <p><a href="<?=$this->url($searchObject->getSearchAction()) . $searchObject->getUrl()->setLimit($searchObject->getDefaultLimit())?>"><?=$this->transEsc('More Summon results')?>...</a></p>
+  <p><a href="<?=$this->url($searchObject->getOptions()->getSearchAction()) . $searchObject->getUrl()->setLimit($searchObject->getOptions()->getDefaultLimit())?>"><?=$this->transEsc('More Summon results')?>...</a></p>
 </div>
 <? endif ?>
\ No newline at end of file
diff --git a/themes/blueprint/templates/search/history-table.phtml b/themes/blueprint/templates/search/history-table.phtml
index 86db750231c..9bd65130976 100644
--- a/themes/blueprint/templates/search/history-table.phtml
+++ b/themes/blueprint/templates/search/history-table.phtml
@@ -10,7 +10,7 @@
     <tr class="<?=$iteration % 2 == 1 ? 'even' : 'odd'?>row">
       <td><?=$this->escapeHtml(date("g:ia, jS M y", $info->getStartTime()))?></td>
       <td>
-        <a href="<?=$this->url($info->getSearchAction()) . $info->getUrl()->getParams()?>"><?
+        <a href="<?=$this->url($info->getOptions()->getSearchAction()) . $info->getUrl()->getParams()?>"><?
           $desc = $info->getDisplayQuery();
           echo empty($desc) ? $this->transEsc("history_empty_search") : $this->escapeHtml($desc);
         ?></a>
diff --git a/themes/jquerymobile/templates/search/history-table.phtml b/themes/jquerymobile/templates/search/history-table.phtml
index 7f45b78a273..1a58c6db14a 100644
--- a/themes/jquerymobile/templates/search/history-table.phtml
+++ b/themes/jquerymobile/templates/search/history-table.phtml
@@ -1,6 +1,6 @@
 <? foreach (($this->showSaved ? array_reverse($this->saved) : array_reverse($this->unsaved)) as $iteration => $info): ?>
   <li>
-    <a rel="external" href="<?=$this->url($info->getSearchAction()) . $info->getUrl()->getParams()?>">
+    <a rel="external" href="<?=$this->url($info->getOptions()->getSearchAction()) . $info->getUrl()->getParams()?>">
     <div class="result">
     <h3><?
       $desc = $info->getDisplayQuery();
-- 
GitLab