From a2afc812cadcd3306e290559ff811f75bea64f08 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Thu, 28 Jul 2011 05:48:57 +0000 Subject: [PATCH] Make mw.user.options and mw.user.tokens work in debug mode in IE. Now that mw.user is a separate module, we have to make these depend on that and make sure dependencies are actually processed. * Make ResourceLoaderUserOptionsModule and ResourceLoaderUserTokensModule depend on mw.user * Load mw.user.{tokens,options,groups} load as TYPE_COMBINED instead of TYPE_SCRIPT. The latter wouldn't wrap the code in mw.loader.implement() ** ...but make sure 'user' (user scripts) is excluded, that one needs to not be wrapped in a closure * Make TYPE_COMBINED actually work in makeResourceLoaderLink() * Add a comment in makeModuleResponse() to explain what the weird is_array( $scripts ) stuff is all about * Add FIXME about how mw.user.options should split off the CSS part into a separate module --- includes/OutputPage.php | 13 +++++++++---- includes/resourceloader/ResourceLoader.php | 2 ++ .../ResourceLoaderUserOptionsModule.php | 6 ++++++ .../ResourceLoaderUserTokensModule.php | 4 ++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 067158b330..8a90c1da22 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2403,8 +2403,10 @@ $templates 'lang' => $this->getContext()->getLang()->getCode(), 'debug' => ResourceLoader::inDebugMode() ? 'true' : 'false', 'skin' => $this->getSkin()->getSkinName(), - 'only' => $only, ); + if ( $only !== ResourceLoaderModule::TYPE_COMBINED ) { + $baseQuery['only'] = $only; + } // Propagate printable and handheld parameters if present if ( $this->isPrintable() ) { $baseQuery['printable'] = 1; @@ -2622,11 +2624,14 @@ $templates $scripts .= Html::inlineScript( "\n" . $this->getRequest()->getText( 'wpTextbox1' ) . "\n" ) . "\n"; } else { # @todo FIXME: This means that User:Me/Common.js doesn't load when previewing - # User:Me/Vector.js, and vice versa (bug26283) - $userScripts[] = 'user'; + # User:Me/Vector.js, and vice versa (bug 26283) + + // We can't do $userScripts[] = 'user'; because the user module would end up + // being wrapped in a closure, so load it raw like 'site' + $scripts .= $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_SCRIPTS ); } } - $scripts .= $this->makeResourceLoaderLink( $userScripts, ResourceLoaderModule::TYPE_SCRIPTS ); + $scripts .= $this->makeResourceLoaderLink( $userScripts, ResourceLoaderModule::TYPE_COMBINED ); return $scripts; } diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index af75a9f052..1d226bd863 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -549,8 +549,10 @@ class ResourceLoader { switch ( $context->getOnly() ) { case 'scripts': if ( is_string( $scripts ) ) { + // Load scripts raw... $out .= $scripts; } elseif ( is_array( $scripts ) ) { + // ...except when $scripts is an array of URLs $out .= self::makeLoaderImplementScript( $name, $scripts, array(), array() ); } break; diff --git a/includes/resourceloader/ResourceLoaderUserOptionsModule.php b/includes/resourceloader/ResourceLoaderUserOptionsModule.php index 7b600ea37e..e7f29053f5 100644 --- a/includes/resourceloader/ResourceLoaderUserOptionsModule.php +++ b/includes/resourceloader/ResourceLoaderUserOptionsModule.php @@ -84,6 +84,8 @@ class ResourceLoaderUserOptionsModule extends ResourceLoaderModule { * @return array */ public function getStyles( ResourceLoaderContext $context ) { + // FIXME: This stuff should really be in its own module, because it gets double-loaded otherwise + // (once through a , once when embedded as JS) global $wgAllowUserCssPrefs; if ( $wgAllowUserCssPrefs ) { @@ -129,4 +131,8 @@ class ResourceLoaderUserOptionsModule extends ResourceLoaderModule { public function getGroup() { return 'private'; } + + public function getDependencies() { + return array( 'mediawiki.user' ); + } } diff --git a/includes/resourceloader/ResourceLoaderUserTokensModule.php b/includes/resourceloader/ResourceLoaderUserTokensModule.php index 9403534c07..e54e5dcf13 100644 --- a/includes/resourceloader/ResourceLoaderUserTokensModule.php +++ b/includes/resourceloader/ResourceLoaderUserTokensModule.php @@ -60,4 +60,8 @@ class ResourceLoaderUserTokensModule extends ResourceLoaderModule { public function getGroup() { return 'private'; } + + public function getDependencies() { + return array( 'mediawiki.user' ); + } } -- 2.20.1