resourceloader: Remove unused 'getBaseModulesInternal' internal method
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderStartUpModule.php
index 2959b22..a982de2 100644 (file)
@@ -70,7 +70,6 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                // Build list of variables
                $skin = $context->getSkin();
                $vars = [
-                       'wgLoadScript' => $conf->get( 'LoadScript' ),
                        'debug' => $context->getDebug(),
                        'skin' => $skin,
                        'stylepath' => $conf->get( 'StylePath' ),
@@ -106,8 +105,6 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
                        'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass( Title::legalChars() ),
                        'wgIllegalFileChars' => Title::convertByteClassToUnicodeClass( $illegalFileChars ),
-                       'wgResourceLoaderStorageVersion' => $conf->get( 'ResourceLoaderStorageVersion' ),
-                       'wgResourceLoaderStorageEnabled' => $conf->get( 'ResourceLoaderStorageEnabled' ),
                        'wgForeignUploadTargets' => $conf->get( 'ForeignUploadTargets' ),
                        'wgEnableUploads' => $conf->get( 'EnableUploads' ),
                        'wgCommentByteLimit' => null,
@@ -286,8 +283,9 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        }
 
                        if ( $versionHash !== '' && strlen( $versionHash ) !== 7 ) {
-                               $this->getLogger()->warning(
-                                       "Module '{module}' produced an invalid version hash: '{version}'.",
+                               $e = new RuntimeException( "Badly formatted module version hash" );
+                               $resourceLoader->outputErrorAndLog( $e,
+                                               "Module '{module}' produced an invalid version hash: '{version}'.",
                                        [
                                                'module' => $name,
                                                'version' => $versionHash,
@@ -342,16 +340,6 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                return $out;
        }
 
-       /**
-        * @private For internal use by SpecialJavaScriptTest
-        * @since 1.32
-        * @return array
-        * @codeCoverageIgnore
-        */
-       public function getBaseModulesInternal() {
-               return $this->getBaseModules();
-       }
-
        /**
         * Base modules implicitly available to all modules.
         *
@@ -368,6 +356,30 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                return $baseModules;
        }
 
+       /**
+        * Get the localStorage key for the entire module store. The key references
+        * $wgDBname to prevent clashes between wikis under the same web domain.
+        *
+        * @return string localStorage item key for JavaScript
+        */
+       private function getStoreKey() {
+               return 'MediaWikiModuleStore:' . $this->getConfig()->get( 'DBname' );
+       }
+
+       /**
+        * Get the key on which the JavaScript module cache (mw.loader.store) will vary.
+        *
+        * @param ResourceLoaderContext $context
+        * @return string String of concatenated vary conditions
+        */
+       private function getStoreVary( ResourceLoaderContext $context ) {
+               return implode( ':', [
+                       $context->getSkin(),
+                       $this->getConfig()->get( 'ResourceLoaderStorageVersion' ),
+                       $context->getLanguage(),
+               ] );
+       }
+
        /**
         * @param ResourceLoaderContext $context
         * @return string JavaScript code
@@ -400,6 +412,16 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        '$VARS.maxQueryLength' => ResourceLoader::encodeJsonForScript(
                                $conf->get( 'ResourceLoaderMaxQueryLength' )
                        ),
+                       // The client-side module cache can be disabled by site configuration.
+                       // It is also always disabled in debug mode.
+                       '$VARS.storeEnabled' => ResourceLoader::encodeJsonForScript(
+                               $conf->get( 'ResourceLoaderStorageEnabled' ) && !$context->getDebug()
+                       ),
+                       '$VARS.wgLegacyJavaScriptGlobals' => ResourceLoader::encodeJsonForScript(
+                               $conf->get( 'LegacyJavaScriptGlobals' )
+                       ),
+                       '$VARS.storeKey' => ResourceLoader::encodeJsonForScript( $this->getStoreKey() ),
+                       '$VARS.storeVary' => ResourceLoader::encodeJsonForScript( $this->getStoreVary( $context ) ),
                ];
                $profilerStubs = [
                        '$CODE.profileExecuteStart();' => 'mw.loader.profiler.onExecuteStart( module );',
@@ -418,9 +440,6 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
 
                // Perform string replacements for startup.js
                $pairs = [
-                       '$VARS.wgLegacyJavaScriptGlobals' => ResourceLoader::encodeJsonForScript(
-                               $conf->get( 'LegacyJavaScriptGlobals' )
-                       ),
                        '$VARS.configuration' => ResourceLoader::encodeJsonForScript(
                                $this->getConfigSettings( $context )
                        ),