resourceloader: ResourceLoaderGetConfigVars is passed skin
authorjdlrobson <jdlrobson@gmail.com>
Wed, 10 Oct 2018 17:25:28 +0000 (10:25 -0700)
committerJdlrobson <jrobson@wikimedia.org>
Mon, 22 Oct 2018 18:55:44 +0000 (18:55 +0000)
The startup module varies by skin, so it should be possible for
consumers of the ResourceLoaderGetConfigVars hook to know what
skin it being requested.

Bug: T186062
Change-Id: I97d6b4bc245bc64ff148c3665b46116b8a6be409

docs/hooks.txt
includes/resourceloader/ResourceLoaderStartUpModule.php

index 90b2b05..96ddf1d 100644 (file)
@@ -2877,7 +2877,9 @@ $context: ResourceLoaderContext|null
 ResourceLoaderStartUpModule::getConfigSettings(). Use this to export static
 configuration variables to JavaScript. Things that depend on the current page
 or request state must be added through MakeGlobalVariablesScript instead.
+Skin is made available for skin specific config.
 &$vars: [ variable name => value ]
+$skin: Skin
 
 'ResourceLoaderJqueryMsgModuleMagicWords': Called in
 ResourceLoaderJqueryMsgModule to allow adding magic words for jQueryMsg.
index e4a753f..b5d31ef 100644 (file)
@@ -78,10 +78,11 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
 
                // Build list of variables
+               $skin = $context->getSkin();
                $vars = [
                        'wgLoadScript' => wfScript( 'load' ),
                        'debug' => $context->getDebug(),
-                       'skin' => $context->getSkin(),
+                       'skin' => $skin,
                        'stylepath' => $conf->get( 'StylePath' ),
                        'wgUrlProtocols' => wfUrlProtocols(),
                        'wgArticlePath' => $conf->get( 'ArticlePath' ),
@@ -126,7 +127,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgCommentCodePointLimit' => $oldCommentSchema ? null : CommentStore::COMMENT_CHARACTER_LIMIT,
                ];
 
-               Hooks::run( 'ResourceLoaderGetConfigVars', [ &$vars ] );
+               Hooks::run( 'ResourceLoaderGetConfigVars', [ &$vars, $skin ] );
 
                return $vars;
        }