Merge "RevisionStoreDbTestBase, remove redundant needsDB override"
[lhc/web/wiklou.git] / includes / parser / CoreParserFunctions.php
index 3c47de3..d44ac8c 100644 (file)
@@ -98,11 +98,6 @@ class CoreParserFunctions {
                        $args = array_slice( func_get_args(), 2 );
                        $message = wfMessage( $part1, $args )
                                ->inLanguage( $parser->getOptions()->getUserLangObj() );
-                       if ( !$message->exists() ) {
-                               // When message does not exists, the message name is surrounded by angle
-                               // and can result in a tag, therefore escape the angles
-                               return $message->escaped();
-                       }
                        return [ $message->plain(), 'noparse' => false ];
                } else {
                        return [ 'found' => false ];
@@ -135,14 +130,13 @@ class CoreParserFunctions {
        }
 
        public static function ns( $parser, $part1 = '' ) {
-               global $wgContLang;
                if ( intval( $part1 ) || $part1 == "0" ) {
                        $index = intval( $part1 );
                } else {
-                       $index = $wgContLang->getNsIndex( str_replace( ' ', '_', $part1 ) );
+                       $index = $parser->getContentLanguage()->getNsIndex( str_replace( ' ', '_', $part1 ) );
                }
                if ( $index !== false ) {
-                       return $wgContLang->getFormattedNsText( $index );
+                       return $parser->getContentLanguage()->getFormattedNsText( $index );
                } else {
                        return [ 'found' => false ];
                }
@@ -197,13 +191,11 @@ class CoreParserFunctions {
        }
 
        public static function lcfirst( $parser, $s = '' ) {
-               global $wgContLang;
-               return $wgContLang->lcfirst( $s );
+               return $parser->getContentLanguage()->lcfirst( $s );
        }
 
        public static function ucfirst( $parser, $s = '' ) {
-               global $wgContLang;
-               return $wgContLang->ucfirst( $s );
+               return $parser->getContentLanguage()->ucfirst( $s );
        }
 
        /**
@@ -212,8 +204,7 @@ class CoreParserFunctions {
         * @return string
         */
        public static function lc( $parser, $s = '' ) {
-               global $wgContLang;
-               return $parser->markerSkipCallback( $s, [ $wgContLang, 'lc' ] );
+               return $parser->markerSkipCallback( $s, [ $parser->getContentLanguage(), 'lc' ] );
        }
 
        /**
@@ -222,8 +213,7 @@ class CoreParserFunctions {
         * @return string
         */
        public static function uc( $parser, $s = '' ) {
-               global $wgContLang;
-               return $parser->markerSkipCallback( $s, [ $wgContLang, 'uc' ] );
+               return $parser->markerSkipCallback( $s, [ $parser->getContentLanguage(), 'uc' ] );
        }
 
        public static function localurl( $parser, $s = '', $arg = null ) {
@@ -742,7 +732,6 @@ class CoreParserFunctions {
         * @return string
         */
        public static function pagesincategory( $parser, $name = '', $arg1 = null, $arg2 = null ) {
-               global $wgContLang;
                static $magicWords = null;
                if ( is_null( $magicWords ) ) {
                        $magicWords = $parser->getMagicWordFactory()->newArray( [
@@ -772,7 +761,7 @@ class CoreParserFunctions {
                if ( !$title ) { # invalid title
                        return self::formatRaw( 0, $raw, $parser->getFunctionLang() );
                }
-               $wgContLang->findVariantLink( $name, $title, true );
+               $parser->getContentLanguage()->findVariantLink( $name, $title, true );
 
                // Normalize name for cache
                $name = $title->getDBkey();
@@ -956,7 +945,8 @@ class CoreParserFunctions {
        }
 
        public static function special( $parser, $text ) {
-               list( $page, $subpage ) = SpecialPageFactory::resolveAlias( $text );
+               list( $page, $subpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+                       resolveAlias( $text );
                if ( $page ) {
                        $title = SpecialPage::getTitleFor( $page, $subpage );
                        return $title->getPrefixedText();