Merge "Add Special:Search sort parameter without ui"
[lhc/web/wiklou.git] / includes / search / SearchEngine.php
index 99bdabe..ad9f934 100644 (file)
@@ -234,10 +234,8 @@ abstract class SearchEngine {
         * @return string
         */
        public function normalizeText( $string ) {
-               global $wgContLang;
-
                // Some languages such as Chinese require word segmentation
-               return $wgContLang->segmentByWord( $string );
+               return MediaWikiServices::getInstance()->getContentLanguage()->segmentByWord( $string );
        }
 
        /**
@@ -259,8 +257,8 @@ abstract class SearchEngine {
         * @return SearchNearMatcher
         */
        public function getNearMatcher( Config $config ) {
-               global $wgContLang;
-               return new SearchNearMatcher( $config, $wgContLang );
+               return new SearchNearMatcher( $config,
+                       MediaWikiServices::getInstance()->getContentLanguage() );
        }
 
        /**
@@ -268,8 +266,9 @@ abstract class SearchEngine {
         * @return SearchNearMatcher
         */
        protected static function defaultNearMatcher() {
-               $config = MediaWikiServices::getInstance()->getMainConfig();
-               return MediaWikiServices::getInstance()->newSearchEngine()->getNearMatcher( $config );
+               $services = MediaWikiServices::getInstance();
+               $config = $services->getMainConfig();
+               return $services->newSearchEngine()->getNearMatcher( $config );
        }
 
        /**
@@ -417,8 +416,6 @@ abstract class SearchEngine {
                $withAllKeyword = true,
                $withPrefixSearchExtractNamespaceHook = false
        ) {
-               global $wgContLang;
-
                $parsed = $query;
                if ( strpos( $query, ':' ) === false ) { // nothing to do
                        return false;
@@ -447,7 +444,7 @@ abstract class SearchEngine {
 
                if ( !$allQuery && strpos( $query, ':' ) !== false ) {
                        $prefix = str_replace( ' ', '_', substr( $query, 0, strpos( $query, ':' ) ) );
-                       $index = $wgContLang->getNsIndex( $prefix );
+                       $index = MediaWikiServices::getInstance()->getContentLanguage()->getNsIndex( $prefix );
                        if ( $index !== false ) {
                                $extractedNamespace = [ $index ];
                                $parsed = substr( $query, strlen( $prefix ) + 1 );
@@ -627,9 +624,8 @@ abstract class SearchEngine {
                $results = $this->completionSearchBackendOverfetch( $search );
                $fallbackLimit = 1 + $this->limit - $results->getSize();
                if ( $fallbackLimit > 0 ) {
-                       global $wgContLang;
-
-                       $fallbackSearches = $wgContLang->autoConvertToAllVariants( $search );
+                       $fallbackSearches = MediaWikiServices::getInstance()->getContentLanguage()->
+                               autoConvertToAllVariants( $search );
                        $fallbackSearches = array_diff( array_unique( $fallbackSearches ), [ $search ] );
 
                        foreach ( $fallbackSearches as $fbs ) {