Merge "HTML escape parameter 'text' of hook 'SkinEditSectionLinks'"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderStartUpModule.php
index 334fc73..8cbde09 100644 (file)
@@ -49,16 +49,6 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
        private function getConfigSettings( $context ) {
                $conf = $this->getConfig();
 
-               // We can't use Title::newMainPage() if 'mainpage' is in
-               // $wgForceUIMsgAsContentMsg because that will try to use the session
-               // user's language and we have no session user. This does the
-               // equivalent but falling back to our ResourceLoaderContext language
-               // instead.
-               $mainPage = Title::newFromText( $context->msg( 'mainpage' )->inContentLanguage()->text() );
-               if ( !$mainPage ) {
-                       $mainPage = Title::newFromText( 'Main Page' );
-               }
-
                /**
                 * Namespace related preparation
                 * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
@@ -67,9 +57,10 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                $contLang = MediaWikiServices::getInstance()->getContentLanguage();
                $namespaceIds = $contLang->getNamespaceIds();
                $caseSensitiveNamespaces = [];
-               foreach ( MWNamespace::getCanonicalNamespaces() as $index => $name ) {
+               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
+               foreach ( $nsInfo->getCanonicalNamespaces() as $index => $name ) {
                        $namespaceIds[$contLang->lc( $name )] = $index;
-                       if ( !MWNamespace::isCapitalized( $index ) ) {
+                       if ( !$nsInfo->isCapitalized( $index ) ) {
                                $caseSensitiveNamespaces[] = $index;
                        }
                }
@@ -100,21 +91,18 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgVersion' => $conf->get( 'Version' ),
                        'wgEnableAPI' => true, // Deprecated since MW 1.32
                        'wgEnableWriteAPI' => true, // Deprecated since MW 1.32
-                       'wgMainPageTitle' => $mainPage->getPrefixedText(),
                        'wgFormattedNamespaces' => $contLang->getFormattedNamespaces(),
                        'wgNamespaceIds' => $namespaceIds,
-                       'wgContentNamespaces' => MWNamespace::getContentNamespaces(),
+                       'wgContentNamespaces' => $nsInfo->getContentNamespaces(),
                        'wgSiteName' => $conf->get( 'Sitename' ),
                        'wgDBname' => $conf->get( 'DBname' ),
                        'wgExtraSignatureNamespaces' => $conf->get( 'ExtraSignatureNamespaces' ),
-                       'wgAvailableSkins' => Skin::getSkinNames(),
                        'wgExtensionAssetsPath' => $conf->get( 'ExtensionAssetsPath' ),
                        // MediaWiki sets cookies to have this prefix by default
                        'wgCookiePrefix' => $conf->get( 'CookiePrefix' ),
                        'wgCookieDomain' => $conf->get( 'CookieDomain' ),
                        'wgCookiePath' => $conf->get( 'CookiePath' ),
                        'wgCookieExpiration' => $conf->get( 'CookieExpiration' ),
-                       'wgResourceLoaderMaxQueryLength' => $conf->get( 'ResourceLoaderMaxQueryLength' ),
                        'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
                        'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass( Title::legalChars() ),
                        'wgIllegalFileChars' => Title::convertByteClassToUnicodeClass( $illegalFileChars ),
@@ -387,6 +375,8 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
         */
        public function getScript( ResourceLoaderContext $context ) {
                global $IP;
+               $conf = $this->getConfig();
+
                if ( $context->getOnly() !== 'scripts' ) {
                        return '/* Requires only=script */';
                }
@@ -400,13 +390,16 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                if ( $context->getDebug() ) {
                        $mwLoaderCode .= file_get_contents( "$IP/resources/src/startup/mediawiki.log.js" );
                }
-               if ( $this->getConfig()->get( 'ResourceLoaderEnableJSProfiler' ) ) {
+               if ( $conf->get( 'ResourceLoaderEnableJSProfiler' ) ) {
                        $mwLoaderCode .= file_get_contents( "$IP/resources/src/startup/profiler.js" );
                }
 
                // Perform replacements for mediawiki.js
                $mwLoaderPairs = [
                        '$VARS.baseModules' => ResourceLoader::encodeJsonForScript( $this->getBaseModules() ),
+                       '$VARS.maxQueryLength' => ResourceLoader::encodeJsonForScript(
+                               $conf->get( 'ResourceLoaderMaxQueryLength' )
+                       ),
                ];
                $profilerStubs = [
                        '$CODE.profileExecuteStart();' => 'mw.loader.profiler.onExecuteStart( module );',
@@ -414,7 +407,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        '$CODE.profileScriptStart();' => 'mw.loader.profiler.onScriptStart( module );',
                        '$CODE.profileScriptEnd();' => 'mw.loader.profiler.onScriptEnd( module );',
                ];
-               if ( $this->getConfig()->get( 'ResourceLoaderEnableJSProfiler' ) ) {
+               if ( $conf->get( 'ResourceLoaderEnableJSProfiler' ) ) {
                        // When profiling is enabled, insert the calls.
                        $mwLoaderPairs += $profilerStubs;
                } else {
@@ -426,7 +419,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                // Perform string replacements for startup.js
                $pairs = [
                        '$VARS.wgLegacyJavaScriptGlobals' => ResourceLoader::encodeJsonForScript(
-                               $this->getConfig()->get( 'LegacyJavaScriptGlobals' )
+                               $conf->get( 'LegacyJavaScriptGlobals' )
                        ),
                        '$VARS.configuration' => ResourceLoader::encodeJsonForScript(
                                $this->getConfigSettings( $context )