From 990714436e23b3812a265811fb7dfd91e369eeb0 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Thu, 10 Sep 2009 13:07:36 +0000 Subject: [PATCH] API: When returning an emtpy opensearch result because mwsuggest is disabled, return a valid opensearch response. --- includes/api/ApiOpenSearch.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php index db95335045..f71dce5c60 100644 --- a/includes/api/ApiOpenSearch.php +++ b/includes/api/ApiOpenSearch.php @@ -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); -- 2.20.1