From: Krinkle Date: Wed, 28 Dec 2011 22:20:29 +0000 (+0000) Subject: Move embedded ResourceLoader modules to the X-Git-Tag: 1.31.0-rc.0~25695 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=10138296b4b125e6353547a6105c39211626b9cf;hp=d5836e00e1f09dcf7031bf5af1cc3ce15818df0e;p=lhc%2Fweb%2Fwiklou.git Move embedded ResourceLoader modules to the * Embed "private" ResourceLoader modules in the before the first loader link, instead of in the after the last loader link * Wow, was in the opposite place where it should've been :D * Fixes bug 30914 --- diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 6ea996f27c..c75295d115 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -197,6 +197,8 @@ production. * (bug 30711) When adding a new section to a page with section=new, the text is now always added to the current version of the page * (bug 31719) Recognize &ns_svg; as the svg namespace when extracting width +* (bug 30914) Embeddable ResourceLoader modules (user.options, user.tokens) + should be loaded in for proper dependency resolution === API changes in 1.19 === * (bug 19838) siprop=interwikimap can now use the interwiki cache. diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 1273a7f0c1..ee118682c9 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2575,7 +2575,9 @@ $templates continue; } - // Support inlining of private modules if configured as such + // Support inlining of private modules if configured as such. Note that these + // modules should be loaded from getHeadScripts() before the first loader call. + // Otherwise other modules can't properly use them as dependencies (bug 30914) if ( $group === 'private' && $wgResourceLoaderInlinePrivateModules ) { if ( $only == ResourceLoaderModule::TYPE_STYLES ) { $links .= Html::inlineStyle( @@ -2661,6 +2663,10 @@ $templates ) ); + // Load embeddable private modules before any loader links + $embedScripts = array( 'user.options', 'user.tokens' ); + $scripts .= $this->makeResourceLoaderLink( $embedScripts, ResourceLoaderModule::TYPE_COMBINED ); + // Script and Messages "only" requests marked for top inclusion // Messages should go first $scripts .= $this->makeResourceLoaderLink( $this->getModuleMessages( true, 'top' ), ResourceLoaderModule::TYPE_MESSAGES ); @@ -2708,7 +2714,7 @@ $templates // Legacy Scripts $scripts .= "\n" . $this->mScripts; - $userScripts = array( 'user.options', 'user.tokens' ); + $userScripts = array(); // Add site JS if enabled if ( $wgUseSiteJs ) { diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 1024ce5b38..cfc64946d5 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -913,8 +913,7 @@ class ResourceLoader { * @return string */ public static function makeLoaderConditionalScript( $script ) { - $script = str_replace( "\n", "\n\t", trim( $script ) ); - return "if(window.mw){\n\t$script\n}\n"; + return "if(window.mw){\n".trim( $script )."\n}"; } /**