Merge "Revert "Introduce Special:RedirectExternal""
[lhc/web/wiklou.git] / includes / api / ApiQuerySiteinfo.php
index c65dfa5..d134eda 100644 (file)
@@ -125,8 +125,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        protected function appendGeneralInfo( $property ) {
-               global $wgContLang;
-
                $config = $this->getConfig();
 
                $data = [];
@@ -164,8 +162,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $data['langconversion'] = !$config->get( 'DisableLangConversion' );
                $data['titleconversion'] = !$config->get( 'DisableTitleConversion' );
 
-               if ( $wgContLang->linkPrefixExtension() ) {
-                       $linkPrefixCharset = $wgContLang->linkPrefixCharset();
+               $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+               if ( $contLang->linkPrefixExtension() ) {
+                       $linkPrefixCharset = $contLang->linkPrefixCharset();
                        $data['linkprefixcharset'] = $linkPrefixCharset;
                        // For backwards compatibility
                        $data['linkprefix'] = "/^((?>.*[^$linkPrefixCharset]|))(.+)$/sDu";
@@ -174,7 +173,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        $data['linkprefix'] = '';
                }
 
-               $linktrail = $wgContLang->linkTrail();
+               $linktrail = $contLang->linkTrail();
                $data['linktrail'] = $linktrail ?: '';
 
                $data['legaltitlechars'] = Title::legalChars();
@@ -197,26 +196,26 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $data['lang'] = $config->get( 'LanguageCode' );
 
                $fallbacks = [];
-               foreach ( $wgContLang->getFallbackLanguages() as $code ) {
+               foreach ( $contLang->getFallbackLanguages() as $code ) {
                        $fallbacks[] = [ 'code' => $code ];
                }
                $data['fallback'] = $fallbacks;
                ApiResult::setIndexedTagName( $data['fallback'], 'lang' );
 
-               if ( $wgContLang->hasVariants() ) {
+               if ( $contLang->hasVariants() ) {
                        $variants = [];
-                       foreach ( $wgContLang->getVariants() as $code ) {
+                       foreach ( $contLang->getVariants() as $code ) {
                                $variants[] = [
                                        'code' => $code,
-                                       'name' => $wgContLang->getVariantname( $code ),
+                                       'name' => $contLang->getVariantname( $code ),
                                ];
                        }
                        $data['variants'] = $variants;
                        ApiResult::setIndexedTagName( $data['variants'], 'lang' );
                }
 
-               $data['rtl'] = $wgContLang->isRTL();
-               $data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding();
+               $data['rtl'] = $contLang->isRTL();
+               $data['fallback8bitEncoding'] = $contLang->fallback8bitEncoding();
 
                $data['readonly'] = wfReadOnly();
                if ( $data['readonly'] ) {
@@ -280,11 +279,13 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        protected function appendNamespaces( $property ) {
-               global $wgContLang;
                $data = [
                        ApiResult::META_TYPE => 'assoc',
                ];
-               foreach ( $wgContLang->getFormattedNamespaces() as $ns => $title ) {
+               foreach (
+                       MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces()
+                       as $ns => $title
+               ) {
                        $data[$ns] = [
                                'id' => intval( $ns ),
                                'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
@@ -314,10 +315,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        protected function appendNamespaceAliases( $property ) {
-               global $wgContLang;
+               $contLang = MediaWikiServices::getInstance()->getContentLanguage();
                $aliases = array_merge( $this->getConfig()->get( 'NamespaceAliases' ),
-                       $wgContLang->getNamespaceAliases() );
-               $namespaces = $wgContLang->getNamespaces();
+                       $contLang->getNamespaceAliases() );
+               $namespaces = $contLang->getNamespaces();
                $data = [];
                foreach ( $aliases as $title => $ns ) {
                        if ( $namespaces[$ns] == $title ) {
@@ -339,10 +340,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        protected function appendSpecialPageAliases( $property ) {
-               global $wgContLang;
                $data = [];
-               $aliases = $wgContLang->getSpecialPageAliases();
-               foreach ( SpecialPageFactory::getNames() as $specialpage ) {
+               $services = MediaWikiServices::getInstance();
+               $aliases = $services->getContentLanguage()->getSpecialPageAliases();
+               foreach ( $services->getSpecialPageFactory()->getNames() as $specialpage ) {
                        if ( isset( $aliases[$specialpage] ) ) {
                                $arr = [ 'realname' => $specialpage, 'aliases' => $aliases[$specialpage] ];
                                ApiResult::setIndexedTagName( $arr['aliases'], 'alias' );
@@ -355,9 +356,11 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        protected function appendMagicWords( $property ) {
-               global $wgContLang;
                $data = [];
-               foreach ( $wgContLang->getMagicWords() as $magicword => $aliases ) {
+               foreach (
+                       MediaWikiServices::getInstance()->getContentLanguage()->getMagicWords()
+                       as $magicword => $aliases
+               ) {
                        $caseSensitive = array_shift( $aliases );
                        $arr = [ 'name' => $magicword, 'aliases' => $aliases ];
                        $arr['case-sensitive'] = (bool)$caseSensitive;
@@ -698,7 +701,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $data = [];
 
                foreach ( $langNames as $code => $name ) {
-                       $lang = [ 'code' => $code ];
+                       $lang = [
+                               'code' => $code,
+                               'bcp47' => LanguageCode::bcp47( $code ),
+                       ];
                        ApiResult::setContentValue( $lang, 'name', $name );
                        $data[] = $lang;
                }
@@ -782,7 +788,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
        public function appendExtensionTags( $property ) {
                global $wgParser;
-               $wgParser->firstCallInit();
                $tags = array_map(
                        function ( $item ) {
                                return "<$item>";
@@ -797,7 +802,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
        public function appendFunctionHooks( $property ) {
                global $wgParser;
-               $wgParser->firstCallInit();
                $hooks = $wgParser->getFunctionHooks();
                ApiResult::setArrayType( $hooks, 'BCarray' );
                ApiResult::setIndexedTagName( $hooks, 'h' );