Duplicate Expired search generates errors

Xon

Well-known member
Affected version
XF2.2.10
After upgrade to XenForo 2.2.10 seeing in Server error log every couple of hours:
Code:
TypeError: Argument 1 passed to XF\Search\Search::getResultSet() must be of the type array, null given, called in /home/forum/src/XF/Pub/Controller/Search.php on line 156 src/XF/Search/Search.php:253

Stack trace
#0 src/XF/Pub/Controller/Search.php(156): XF\Search\Search->getResultSet(NULL)
#1 src/addons/SV/ElasticSearchEssentials/XF/Pub/Controller/Search.php(454): XF\Pub\Controller\Search->actionResults(Object(XF\Mvc\ParameterBag))
#2 src/XF/Mvc/Dispatcher.php(352): SV\ElasticSearchEssentials\XF\Pub\Controller\Search->actionResults(Object(XF\Mvc\ParameterBag))
#3 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF\\Pub\\Controll...', 'Results', Object(XF\Mvc\RouteMatch), Object(SV\ElasticSearchEssentials\XF\Pub\Controller\Search), Object(XF\Mvc\Reply\Reroute))
#4 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(SV\ElasticSearchEssentials\XF\Pub\Controller\Search), Object(XF\Mvc\Reply\Reroute))
#5 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#6 src/XF/App.php(2353): XF\Mvc\Dispatcher->run()
#7 src/XF.php(524): XF\App->run()
#8 index.php(20): XF::runApp('XF\\Pub\\App')
#9 {main}

Request state
array(4) {
  ["url"] => string(14) "/search/503324"
  ["referrer"] => bool(false)
  ["_GET"] => array(1) {
    ["/search/503324"] => string(0) ""
  }
  ["_POST"] => array(0) {
  }
}

This is from this code change:
PHP:
-            return $this->runSearch($query, $constraints);
+            if ($visitor->user_id)
+            {
+                // always re-run search for logged-in users
+                return $this->runSearch($query, $constraints);
+            }
+            else if ($search && $search->search_query && $search->search_query !== $this->filter('q', 'str'))
+            {
+                return $this->notFound();
+            }
...
        $resultSet = $searcher->getResultSet($search->search_results);
Before the function would re-run the search. Now when $search is empty it falls through and throws an error.
 
Back
Top Bottom