diff --git a/module/VuFind/src/VuFind/Controller/AbstractSearch.php b/module/VuFind/src/VuFind/Controller/AbstractSearch.php index 6978ccfbf893f23b44171ba1b04765c82dc42c56..cd1fd8f1984ce66a9a74dbb6f06933f2beb9cc94 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractSearch.php +++ b/module/VuFind/src/VuFind/Controller/AbstractSearch.php @@ -132,7 +132,7 @@ class AbstractSearch extends AbstractBase $userId = $user ? $user->id : false; if ($search->session_id == $sessId || $search->user_id == $userId) { // They do, deminify it to a new object. - $minSO = unserialize($search->search_object); + $minSO = $search->getSearchObject(); $savedSearch = $minSO->deminify($this->getResultsManager()); // Now redirect to the URL associated with the saved search; this @@ -322,7 +322,7 @@ class AbstractSearch extends AbstractBase } // Restore the full search object: - $minSO = unserialize($search->search_object); + $minSO = $search->getSearchObject(); $savedSearch = $minSO->deminify($this->getResultsManager()); // Fail if this is not the right type of search: diff --git a/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php b/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php index 11154478237bbed05bf1524319c155855f82e02b..c676b2c1aa85acb3e23adc6b827f795af4c7f41d 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/ResultScroller.php @@ -343,7 +343,7 @@ class ResultScroller extends AbstractPlugin $searchTable = $this->getController()->getTable('Search'); $row = $searchTable->getRowById($this->data->searchId, false); if (!empty($row)) { - $minSO = unserialize($row->search_object); + $minSO = $row->getSearchObject(); $manager = $this->getController()->getServiceLocator() ->get('VuFind\SearchResultsPluginManager'); $search = $minSO->deminify($manager); diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php index ef7a1826242477a55505437ed412506f667efa9e..5140a82dde76d1c619ea88072d589e29f3f7e9ee 100644 --- a/module/VuFind/src/VuFind/Controller/SearchController.php +++ b/module/VuFind/src/VuFind/Controller/SearchController.php @@ -257,7 +257,7 @@ class SearchController extends AbstractSearch // Loop through the history foreach ($searchHistory as $current) { - $minSO = unserialize($current->search_object); + $minSO = $current->getSearchObject(); // Saved searches if ($current->saved == 1) { diff --git a/module/VuFind/src/VuFind/Db/Row/Search.php b/module/VuFind/src/VuFind/Db/Row/Search.php index 7b203a0f318f5238a930900ce1254472ed5bf8b1..0f1fcaaeba7ec7de47cdfcc7649eb5ce9a87e129 100644 --- a/module/VuFind/src/VuFind/Db/Row/Search.php +++ b/module/VuFind/src/VuFind/Db/Row/Search.php @@ -48,4 +48,33 @@ class Search extends RowGateway { parent::__construct('id', 'search', $adapter); } + + /** + * Get the search object from the row + * + * @return \VuFind\Search\Minified + */ + public function getSearchObject() + { + // Resource check for PostgreSQL compatibility: + $raw = is_resource($this->search_object) + ? stream_get_contents($this->search_object) : $this->search_object; + return unserialize($raw); + } + + /** + * Save + * + * @return int + */ + public function save() + { + // Note that if we have a resource, we need to grab the contents before + // saving -- this is necessary for PostgreSQL compatibility although MySQL + // returns a plain string + $this->search_object = is_resource($this->search_object) + ? stream_get_contents($this->search_object) + : $this->search_object; + parent::save(); + } } diff --git a/module/VuFind/src/VuFind/Db/Table/Search.php b/module/VuFind/src/VuFind/Db/Table/Search.php index 18c28ec3a1fa02d895f2062d193b17939cebb7ae..bf6cb46b4f0dc2348018ec7d2536f94974a20b72 100644 --- a/module/VuFind/src/VuFind/Db/Table/Search.php +++ b/module/VuFind/src/VuFind/Db/Table/Search.php @@ -157,11 +157,7 @@ class Search extends Gateway // Deminify the old search (note that if we have a resource, we need // to grab the contents -- this is necessary for PostgreSQL compatibility // although MySQL returns a plain string). - $minSO = unserialize( - is_resource($oldSearch->search_object) - ? stream_get_contents($oldSearch->search_object) - : $oldSearch->search_object - ); + $minSO = $oldSearch->getSearchObject(); $dupSearch = $minSO->deminify($manager); // See if the classes and urls match $oldUrl = $dupSearch->getUrlQuery()->getParams();