Write Latin and other scripts with captial letter
[lhc/web/wiklou.git] / includes / search / SearchSqlite.php
index 0ed477a..6332ea2 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup Search
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Search engine hook for SQLite
  * @ingroup Search
@@ -43,7 +45,6 @@ class SearchSqlite extends SearchDatabase {
         * @return string
         */
        private function parseQuery( $filteredText, $fulltext ) {
-               global $wgContLang;
                $lc = $this->legalSearchChars( self::CHARS_NO_SYNTAX ); // Minus syntax chars (" and *)
                $searchon = '';
                $this->searchTerms = [];
@@ -70,7 +71,8 @@ class SearchSqlite extends SearchDatabase {
 
                                // Some languages such as Serbian store the input form in the search index,
                                // so we may need to search for matches in multiple writing system variants.
-                               $convertedVariants = $wgContLang->autoConvertToAllVariants( $term );
+                               $convertedVariants = MediaWikiServices::getInstance()->getContentLanguage()->
+                                       autoConvertToAllVariants( $term );
                                if ( is_array( $convertedVariants ) ) {
                                        $variants = array_unique( array_values( $convertedVariants ) );
                                } else {
@@ -82,7 +84,8 @@ class SearchSqlite extends SearchDatabase {
                                // fulltext engine.
                                // For Chinese this also inserts spaces between adjacent Han characters.
                                $strippedVariants = array_map(
-                                       [ $wgContLang, 'normalizeForSearch' ],
+                                       [ MediaWikiServices::getInstance()->getContentLanguage(),
+                                               'normalizeForSearch' ],
                                        $variants );
 
                                // Some languages such as Chinese force all variants to a canonical
@@ -123,10 +126,8 @@ class SearchSqlite extends SearchDatabase {
        }
 
        private function regexTerm( $string, $wildcard ) {
-               global $wgContLang;
-
                $regex = preg_quote( $string, '/' );
-               if ( $wgContLang->hasWordBreaks() ) {
+               if ( MediaWikiServices::getInstance()->getContentLanguage()->hasWordBreaks() ) {
                        if ( $wildcard ) {
                                // Don't cut off the final bit!
                                $regex = "\b$regex";
@@ -136,7 +137,7 @@ class SearchSqlite extends SearchDatabase {
                } else {
                        // For Chinese, words may legitimately abut other words in the text literal.
                        // Don't add \b boundary checks... note this could cause false positives
-                       // for latin chars.
+                       // for Latin chars.
                }
                return $regex;
        }
@@ -171,13 +172,12 @@ class SearchSqlite extends SearchDatabase {
        }
 
        protected function searchInternal( $term, $fulltext ) {
-               global $wgContLang;
-
                if ( !$this->fulltextSearchSupported() ) {
                        return null;
                }
 
-               $filteredTerm = $this->filter( $wgContLang->lc( $term ) );
+               $filteredTerm =
+                       $this->filter( MediaWikiServices::getInstance()->getContentLanguage()->lc( $term ) );
                $resultSet = $this->db->query( $this->getQuery( $filteredTerm, $fulltext ) );
 
                $total = null;