Merge "Workaround image magick issue with greyscale xcf files"
[lhc/web/wiklou.git] / includes / api / ApiOpenSearch.php
index f2bf754..7fb045e 100644 (file)
@@ -45,7 +45,6 @@ class ApiOpenSearch extends ApiBase {
        }
 
        public function execute() {
-               global $wgEnableOpenSearchSuggest, $wgSearchSuggestCacheExpiry;
                $params = $this->extractRequestParams();
                $search = $params['search'];
                $limit = $params['limit'];
@@ -53,35 +52,15 @@ class ApiOpenSearch extends ApiBase {
                $suggest = $params['suggest'];
 
                // Some script that was loaded regardless of wgEnableOpenSearchSuggest, likely cached.
-               if ( $suggest && !$wgEnableOpenSearchSuggest ) {
+               if ( $suggest && !$this->getConfig()->get( 'EnableOpenSearchSuggest' ) ) {
                        $searches = array();
                } else {
                        // Open search results may be stored for a very long time
-                       $this->getMain()->setCacheMaxAge( $wgSearchSuggestCacheExpiry );
+                       $this->getMain()->setCacheMaxAge( $this->getConfig()->get( 'SearchSuggestCacheExpiry' ) );
                        $this->getMain()->setCacheMode( 'public' );
 
-                       $searches = PrefixSearch::titleSearch( $search, $limit,
-                               $namespaces );
-
-                       // if the content language has variants, try to retrieve fallback results
-                       $fallbackLimit = $limit - count( $searches );
-                       if ( $fallbackLimit > 0 ) {
-                               global $wgContLang;
-
-                               $fallbackSearches = $wgContLang->autoConvertToAllVariants( $search );
-                               $fallbackSearches = array_diff( array_unique( $fallbackSearches ), array( $search ) );
-
-                               foreach ( $fallbackSearches as $fbs ) {
-                                       $fallbackSearchResult = PrefixSearch::titleSearch( $fbs, $fallbackLimit,
-                                               $namespaces );
-                                       $searches = array_merge( $searches, $fallbackSearchResult );
-                                       $fallbackLimit -= count( $fallbackSearchResult );
-
-                                       if ( $fallbackLimit == 0 ) {
-                                               break;
-                                       }
-                               }
-                       }
+                       $searcher = new StringPrefixSearch;
+                       $searches = $searcher->searchWithVariants( $search, $limit, $namespaces );
                }
                // Set top level elements
                $result = $this->getResult();
@@ -90,12 +69,10 @@ class ApiOpenSearch extends ApiBase {
        }
 
        public function getAllowedParams() {
-               global $wgOpenSearchDefaultLimit;
-
                return array(
                        'search' => null,
                        'limit' => array(
-                               ApiBase::PARAM_DFLT => $wgOpenSearchDefaultLimit,
+                               ApiBase::PARAM_DFLT => $this->getConfig()->get( 'OpenSearchDefaultLimit' ),
                                ApiBase::PARAM_TYPE => 'limit',
                                ApiBase::PARAM_MIN => 1,
                                ApiBase::PARAM_MAX => 100,