From: Timo Tijhof Date: Sun, 10 Apr 2016 02:05:14 +0000 (+0100) Subject: resourceloader: Fold legacy modules into base modules request X-Git-Tag: 1.31.0-rc.0~3518^2 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=0ac6076b4c0848568868bf36b4d9506ad990160b;p=lhc%2Fweb%2Fwiklou.git resourceloader: Fold legacy modules into base modules request Follows-up 0ac4f998 (restore "blocking" legacy modules). After d790562, legacy modules in the top queue were no longer consistently loaded before the bottom queue due to the top queue being async. The implied dependency was made explicit by 0ac4f998 by forcing all modules to wait for legacy modules before executing. This had the negative side-effect of putting an extra HTTP request between the startup module request, base modules request, and actual execution of page modules. (Indentation aligns with when a request is triggered.) Before: 1. Request: Startup module. 2. Request: Base modules 3. Request: Legacy modules 4. Page module request (or local store hit) and execution After: 1. Request: Startup module. 2. Request: Base+legacy modules 3. Page module request (or local store hit) and execution This could alternatively be fixed by moving the top queue to be before the embedded modules and enforcing the embed in a different way. It could also be fixed by debouncing module load calls so they naturally end up in the same request as page modules. However for now I'm addressing this by adding legacy modules to the list of modules in the initial load request from the startup module. This was not possible before because the legacy wikibits had dependencies and base modules cannot have dependencies. Fixed in I7f9f61ea81ad1ef. Bug: T159911 Change-Id: I54f087655e1cde1b8ff1ca5fe56e82f7f7d80965 --- diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index 04b2f72d5d..d92dc0ab6a 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -112,7 +112,6 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { 'wgIllegalFileChars' => Title::convertByteClassToUnicodeClass( $illegalFileChars ), 'wgResourceLoaderStorageVersion' => $conf->get( 'ResourceLoaderStorageVersion' ), 'wgResourceLoaderStorageEnabled' => $conf->get( 'ResourceLoaderStorageEnabled' ), - 'wgResourceLoaderLegacyModules' => self::getLegacyModules(), 'wgForeignUploadTargets' => $conf->get( 'ForeignUploadTargets' ), 'wgEnableUploads' => $conf->get( 'EnableUploads' ), ]; @@ -330,9 +329,11 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { */ public static function getStartupModulesUrl( ResourceLoaderContext $context ) { $rl = $context->getResourceLoader(); - $derivative = new DerivativeResourceLoaderContext( $context ); - $derivative->setModules( self::getStartupModules() ); + $derivative->setModules( array_merge( + self::getStartupModules(), + self::getLegacyModules() + ) ); $derivative->setOnly( 'scripts' ); // Must setModules() before makeVersionQuery() $derivative->setVersion( $rl->makeVersionQuery( $derivative ) ); diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index 52678d4ea3..99658f294a 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -164,8 +164,6 @@ abstract class Skin extends ContextSource { 'content' => [ 'mediawiki.page.ready', ], - // modules that exist for legacy reasons - 'legacy' => ResourceLoaderStartUpModule::getLegacyModules(), // modules relating to search functionality 'search' => [], // modules relating to functionality relating to watching an article diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index 86a9a0af1b..a49db791a8 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -1270,10 +1270,7 @@ registry[ module ].state = 'executing'; runScript = function () { - var script, markModuleReady, nestedAddScript, legacyWait, implicitDependencies, - // Expand to include dependencies since we have to exclude both legacy modules - // and their dependencies from the legacyWait (to prevent a circular dependency). - legacyModules = resolve( mw.config.get( 'wgResourceLoaderLegacyModules', [] ) ); + var script, markModuleReady, nestedAddScript, implicitDependencies, implicitWait; script = registry[ module ].script; markModuleReady = function () { @@ -1294,9 +1291,7 @@ } ); }; - implicitDependencies = ( $.inArray( module, legacyModules ) !== -1 ) ? - [] : - legacyModules; + implicitDependencies = []; if ( module === 'user' ) { // Implicit dependency on the site module. Not real dependency because @@ -1304,11 +1299,11 @@ implicitDependencies.push( 'site' ); } - legacyWait = implicitDependencies.length ? + implicitWait = implicitDependencies.length ? mw.loader.using( implicitDependencies ) : $.Deferred().resolve(); - legacyWait.always( function () { + implicitWait.always( function () { try { if ( Array.isArray( script ) ) { nestedAddScript( script, markModuleReady, 0 );