Index: trunk/phase3/includes/api/ApiOpenSearch.php |
— | — | @@ -52,28 +52,30 @@ |
53 | 53 | |
54 | 54 | // MWSuggest or similar hit |
55 | 55 | if ( $suggest && !$wgEnableOpenSearchSuggest ) { |
56 | | - $srchres = array(); |
| 56 | + $searches = array(); |
57 | 57 | } 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 |
60 | 59 | $this->getMain()->setCacheMaxAge( $wgSearchSuggestCacheExpiry ); |
61 | 60 | $this->getMain()->setCacheMode( 'public' ); |
62 | 61 | |
63 | | - $srchres = PrefixSearch::titleSearch( $search, $limit, |
| 62 | + $searches = PrefixSearch::titleSearch( $search, $limit, |
64 | 63 | $namespaces ); |
65 | 64 | |
66 | 65 | // 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 ) { |
69 | 68 | 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, |
74 | 75 | $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 ) { |
78 | 80 | break; |
79 | 81 | } |
80 | 82 | } |
— | — | @@ -82,7 +84,7 @@ |
83 | 85 | // Set top level elements |
84 | 86 | $result = $this->getResult(); |
85 | 87 | $result->addValue( null, 0, $search ); |
86 | | - $result->addValue( null, 1, $srchres ); |
| 88 | + $result->addValue( null, 1, $searches ); |
87 | 89 | } |
88 | 90 | |
89 | 91 | public function getAllowedParams() { |