resourceloader: Set value for getStoreKey in server-side

This change reduces the size of the JavaScript resources.

Change-Id: I850249f910f6275c1b963dc5421ba706ed6e9a56
This commit is contained in:
Fomafix 2019-06-29 09:47:57 +02:00 committed by Timo Tijhof
parent 0a8e37f042
commit 30ddfc8a77
2 changed files with 12 additions and 1 deletions

View file

@ -366,6 +366,16 @@ 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.
*
@ -412,6 +422,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
'$VARS.maxQueryLength' => ResourceLoader::encodeJsonForScript(
$conf->get( 'ResourceLoaderMaxQueryLength' )
),
'$VARS.storeKey' => ResourceLoader::encodeJsonForScript( $this->getStoreKey() ),
'$VARS.storeVary' => ResourceLoader::encodeJsonForScript( $this->getStoreVary( $context ) ),
];
$profilerStubs = [

View file

@ -2161,7 +2161,7 @@
* @return {string} localStorage item key
*/
getStoreKey: function () {
return 'MediaWikiModuleStore:' + mw.config.get( 'wgDBname' );
return $VARS.storeKey;
},
/**