r56132 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56131‎ | r56132 | r56133 >
Date:13:07, 10 September 2009
Author:catrope
Status:ok (Comments)
Tags:
Comment:
API: When returning an emtpy opensearch result because mwsuggest is disabled, return a valid opensearch response.
Modified paths:
  • /trunk/phase3/includes/api/ApiOpenSearch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiOpenSearch.php
@@ -48,14 +48,19 @@
4949 $limit = $params['limit'];
5050 $namespaces = $params['namespace'];
5151 $suggest = $params['suggest'];
52 - # $wgEnableMWSuggest hit incoming when $wgEnableMWSuggest is disabled
53 - if( $suggest && !$wgEnableMWSuggest ) return;
54 -
55 - // Open search results may be stored for a very long time
56 - $this->getMain()->setCacheMaxAge(1200);
5752
58 - $srchres = PrefixSearch::titleSearch( $search, $limit, $namespaces );
 53+ // $wgEnableMWSuggest hit incoming when $wgEnableMWSuggest is
 54+ // disabled
 55+ if( $suggest && !$wgEnableMWSuggest )
 56+ $srchres = array();
 57+ else {
 58+ // Open search results may be stored for a very long
 59+ // time
 60+ $this->getMain()->setCacheMaxAge(1200);
5961
 62+ $srchres = PrefixSearch::titleSearch( $search, $limit,
 63+ $namespaces );
 64+ }
6065 // Set top level elements
6166 $result = $this->getResult();
6267 $result->addValue(null, 0, $search);

Comments

#Comment by Brion VIBBER (talk | contribs)   19:26, 10 September 2009

MWSuggest being on should not be a limiter on opensearch suggest returns; we've been exporting opensearch suggestions for use by browsers etc since before we had MWSearch!

#Comment by Catrope (talk | contribs)   20:00, 10 September 2009

We're only returning an empty result if mwsuggest is disabled AND the call came from mwsuggest (which we know because the &suggest parameter was passed). We do this so that setting $wgEnableMWSuggest = false; for performance reasons really does disable mwsuggest, even for people who have the JS cached.

#Comment by Brion VIBBER (talk | contribs)   20:14, 10 September 2009

yay! Fine then.

Status & tagging log