Add suggest=1 to search suggestion AJAX request. ApiOpenSearch won't execute such...
authorAaron Schulz <aaron@users.mediawiki.org>
Wed, 11 Feb 2009 15:56:53 +0000 (15:56 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Wed, 11 Feb 2009 15:56:53 +0000 (15:56 +0000)
includes/DefaultSettings.php
includes/SearchEngine.php
includes/api/ApiOpenSearch.php

index 8171586..093bf95 100644 (file)
@@ -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:
index 3ea0341..1fdded3 100644 (file)
@@ -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';
        }
 }
 
index 4a673c2..d463833 100644 (file)
@@ -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'
+                       ),
                );
        }