From 0b28c717b26b5f8edfe2adc196ced8fb96f4b67c Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 11 Feb 2009 15:56:53 +0000 Subject: [PATCH] Add suggest=1 to search suggestion AJAX request. ApiOpenSearch won't execute such request if $wgEnableMWSuggest is disabled --- includes/DefaultSettings.php | 2 +- includes/SearchEngine.php | 2 +- includes/api/ApiOpenSearch.php | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 8171586771..093bf95b58 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1463,7 +1463,7 @@ $wgCacheEpoch = '20030516000000'; * to ensure that client-side caches don't keep obsolete copies of global * styles. */ -$wgStyleVersion = '204'; +$wgStyleVersion = '205'; # Server-side caching: diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index 3ea0341d8c..1fdded3b92 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -403,7 +403,7 @@ class SearchEngine { if($wgMWSuggestTemplate) return $wgMWSuggestTemplate; else - return $wgServer . $wgScriptPath . '/api.php?action=opensearch&search={searchTerms}&namespace={namespaces}'; + return $wgServer . $wgScriptPath . '/api.php?action=opensearch&search={searchTerms}&namespace={namespaces}&suggest=1'; } } diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php index 4a673c2154..d463833cd7 100644 --- a/includes/api/ApiOpenSearch.php +++ b/includes/api/ApiOpenSearch.php @@ -42,10 +42,14 @@ class ApiOpenSearch extends ApiBase { } public function execute() { + global $wgEnableMWSuggest; $params = $this->extractRequestParams(); $search = $params['search']; $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); @@ -61,7 +65,7 @@ class ApiOpenSearch extends ApiBase { public function getAllowedParams() { return array ( 'search' => null, - 'limit' => array ( + 'limit' => array( ApiBase :: PARAM_DFLT => 10, ApiBase :: PARAM_TYPE => 'limit', ApiBase :: PARAM_MIN => 1, @@ -73,6 +77,9 @@ class ApiOpenSearch extends ApiBase { ApiBase :: PARAM_TYPE => 'namespace', ApiBase :: PARAM_ISMULTI => true ), + 'suggest' => array( + ApiBase :: PARAM_TYPE => 'integer' + ), ); } -- 2.20.1