r47142 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47141‎ | r47142 | r47143 >
Date:15:56, 11 February 2009
Author:aaron
Status:ok (Comments)
Tags:
Comment:
Add suggest=1 to search suggestion AJAX request. ApiOpenSearch won't execute such request if $wgEnableMWSuggest is disabled
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/SearchEngine.php (modified) (history)
  • /trunk/phase3/includes/api/ApiOpenSearch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SearchEngine.php
@@ -403,7 +403,7 @@
404404 if($wgMWSuggestTemplate)
405405 return $wgMWSuggestTemplate;
406406 else
407 - return $wgServer . $wgScriptPath . '/api.php?action=opensearch&search={searchTerms}&namespace={namespaces}';
 407+ return $wgServer . $wgScriptPath . '/api.php?action=opensearch&search={searchTerms}&namespace={namespaces}&suggest=1';
408408 }
409409 }
410410
Index: trunk/phase3/includes/api/ApiOpenSearch.php
@@ -42,10 +42,14 @@
4343 }
4444
4545 public function execute() {
 46+ global $wgEnableMWSuggest;
4647 $params = $this->extractRequestParams();
4748 $search = $params['search'];
4849 $limit = $params['limit'];
4950 $namespaces = $params['namespace'];
 51+ $suggest = $params['suggest'];
 52+ # $wgEnableMWSuggest hit incoming when $wgEnableMWSuggest is disabled
 53+ if( $suggest && !$wgEnableMWSuggest ) return;
5054
5155 // Open search results may be stored for a very long time
5256 $this->getMain()->setCacheMaxAge(1200);
@@ -61,7 +65,7 @@
6266 public function getAllowedParams() {
6367 return array (
6468 'search' => null,
65 - 'limit' => array (
 69+ 'limit' => array(
6670 ApiBase :: PARAM_DFLT => 10,
6771 ApiBase :: PARAM_TYPE => 'limit',
6872 ApiBase :: PARAM_MIN => 1,
@@ -73,6 +77,9 @@
7478 ApiBase :: PARAM_TYPE => 'namespace',
7579 ApiBase :: PARAM_ISMULTI => true
7680 ),
 81+ 'suggest' => array(
 82+ ApiBase :: PARAM_TYPE => 'integer'
 83+ ),
7784 );
7885 }
7986
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1463,7 +1463,7 @@
14641464 * to ensure that client-side caches don't keep obsolete copies of global
14651465 * styles.
14661466 */
1467 -$wgStyleVersion = '204';
 1467+$wgStyleVersion = '205';
14681468
14691469
14701470 # Server-side caching:

Follow-up revisions

RevisionCommit summaryAuthorDate
r47188API: Fix up r47142: use a boolean parameter for suggestcatrope17:27, 12 February 2009

Comments

#Comment by Catrope (talk | contribs)   17:27, 12 February 2009

Fixed to use a boolean parameter in r47188

#Comment by Aaron Schulz (talk | contribs)   18:02, 12 February 2009

Shouldn't really matter, but I did look for boolean and didn't readily find it

#Comment by Brion VIBBER (talk | contribs)   23:46, 17 February 2009

This perplexed me a bit, but the reasoning appears to be to allow a site to shut off use of the search suggestions on-wiki in a performance situation; disabling the requests at the server end would reduce query load from cached pages which still include the enabled JS.

#Comment by Aaron Schulz (talk | contribs)   01:10, 18 February 2009

Yep

Status & tagging log