r79694 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79693‎ | r79694 | r79695 >
Date:00:31, 6 January 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Minor followup to r79649. Rename variables
Modified paths:
  • /trunk/phase3/includes/api/ApiOpenSearch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiOpenSearch.php
@@ -52,28 +52,30 @@
5353
5454 // MWSuggest or similar hit
5555 if ( $suggest && !$wgEnableOpenSearchSuggest ) {
56 - $srchres = array();
 56+ $searches = array();
5757 } else {
58 - // Open search results may be stored for a very long
59 - // time
 58+ // Open search results may be stored for a very long time
6059 $this->getMain()->setCacheMaxAge( $wgSearchSuggestCacheExpiry );
6160 $this->getMain()->setCacheMode( 'public' );
6261
63 - $srchres = PrefixSearch::titleSearch( $search, $limit,
 62+ $searches = PrefixSearch::titleSearch( $search, $limit,
6463 $namespaces );
6564
6665 // if the content language has variants, try to retrieve fallback results
67 - $fblimit = $limit - count( $srchres );
68 - if ( $fblimit > 0 ) {
 66+ $fallbackLimit = $limit - count( $searches );
 67+ if ( $fallbackLimit > 0 ) {
6968 global $wgContLang;
70 - $fbsearchs = $wgContLang->autoConvertToAllVariants( $search );
71 - $fbsearchs = array_diff( array_unique( $fbsearchs ), ( array ) $search );
72 - foreach ( $fbsearchs as $fbsearch ) {
73 - $_srchres = PrefixSearch::titleSearch( $fbsearch, $fblimit,
 69+
 70+ $fallbackSearches = $wgContLang->autoConvertToAllVariants( $search );
 71+ $fallbackSearches = array_diff( array_unique( $fallbackSearches ), array( $search ) );
 72+
 73+ foreach ( $fallbackSearches as $fbs ) {
 74+ $fallbackSearchResult = PrefixSearch::titleSearch( $fbs, $fallbackLimit,
7475 $namespaces );
75 - $srchres = array_merge( $srchres, $_srchres );
76 - $fblimit -= count( $_srchres );
77 - if ( $fblimit == 0 ) {
 76+ $searches = array_merge( $searches, $fallbackSearchResult );
 77+ $fallbackLimit -= count( $fallbackSearchResult );
 78+
 79+ if ( $fallbackLimit == 0 ) {
7880 break;
7981 }
8082 }
@@ -82,7 +84,7 @@
8385 // Set top level elements
8486 $result = $this->getResult();
8587 $result->addValue( null, 0, $search );
86 - $result->addValue( null, 1, $srchres );
 88+ $result->addValue( null, 1, $searches );
8789 }
8890
8991 public function getAllowedParams() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r797201.17: MFT r79578, r79591, r79593, r79595, r79649, r79650, r79651, r79653, r79...catrope14:48, 6 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79649Add fallback languages support for ApiOpenSearch.philip16:21, 5 January 2011

Comments

#Comment by Catrope (talk | contribs)   12:12, 6 January 2011
-			$srchres = array();
+			$searches = array();

I'm fairly sure that was meant to say "search result" at one point in time.

Status & tagging log