API: When returning an emtpy opensearch result because mwsuggest is disabled, return...
authorRoan Kattouw <catrope@users.mediawiki.org>
Thu, 10 Sep 2009 13:07:36 +0000 (13:07 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Thu, 10 Sep 2009 13:07:36 +0000 (13:07 +0000)
includes/api/ApiOpenSearch.php

index db95335..f71dce5 100644 (file)
@@ -48,14 +48,19 @@ class ApiOpenSearch extends ApiBase {
                $limit = $params['limit'];
                $namespaces = $params['namespace'];
                $suggest = $params['suggest'];
-               # $wgEnableMWSuggest hit incoming when $wgEnableMWSuggest is disabled
-               if( $suggest && !$wgEnableMWSuggest ) return;
-               
-               // Open search results may be stored for a very long time
-               $this->getMain()->setCacheMaxAge(1200);
 
-               $srchres = PrefixSearch::titleSearch( $search, $limit, $namespaces );
+               // $wgEnableMWSuggest hit incoming when $wgEnableMWSuggest is 
+               // disabled
+               if( $suggest && !$wgEnableMWSuggest )
+                       $srchres = array();
+               else {
+                       // Open search results may be stored for a very long
+                       // time
+                       $this->getMain()->setCacheMaxAge(1200);
 
+                       $srchres = PrefixSearch::titleSearch( $search, $limit,
+                               $namespaces );
+               }
                // Set top level elements
                $result = $this->getResult();
                $result->addValue(null, 0, $search);