From d059dffa289b0933037c57919d49bb4f64bd0457 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 9 Apr 2019 04:06:38 +0100 Subject: [PATCH] resourceloader: Remove redundant filter() in mw.load.load() This was added for T36853, but never worked and wasn't needed because other parts of the commit for that task did the work already (I guess I was trying both ways and ended up submitting both). * The inline comment claims to remove unknown modules, but doesn't actually. Unknown modules would yield state `null`, which is not filtered out. They are actually filtered out by resolveStubbornly() and sortDependencies(). * The inline comment claims to filter out modules we tried previously and were already known to fail. This would work, if there were modules in such state, but that never happens at this stage because load() is the first thing on the page requesting any modules. Nothing notable happened before that. If this were to change in the future, or in case of user scripts calling mw.loader.load() directly with invalid module names, we're still covered by enqueue() and again by mw.loader.work() - both of which make sure we don't re-request or retry modules, by filtering down to only modules in the 'registered' state. Change-Id: I3b9f1a13379ad41aeabad8111647c0f6eddccdfc --- resources/src/startup/mediawiki.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/resources/src/startup/mediawiki.js b/resources/src/startup/mediawiki.js index 4c20e9dd06..22bd01495d 100644 --- a/resources/src/startup/mediawiki.js +++ b/resources/src/startup/mediawiki.js @@ -2031,7 +2031,7 @@ * "text/javascript"; if no type is provided, text/javascript is assumed. */ load: function ( modules, type ) { - var filtered, l; + var l; // Allow calling with a url or single dependency as a string if ( typeof modules === 'string' ) { @@ -2055,16 +2055,10 @@ modules = [ modules ]; } - // Filter out top-level modules that are unknown or failed to load before. - filtered = modules.filter( function ( module ) { - var state = mw.loader.getState( module ); - return state !== 'error' && state !== 'missing'; - } ); - // Resolve remaining list using the known dependency tree. - // This also filters out modules with unknown dependencies. (T36853) - filtered = resolveStubbornly( filtered ); - // Some modules are not yet ready, add to module load queue. - enqueue( filtered, undefined, undefined ); + // Resolve modules into flat list for internal queuing. + // This also filters out unknown modules and modules with + // unknown dependencies, allowing the rest to continue. (T36853) + enqueue( resolveStubbornly( modules ), undefined, undefined ); }, /** -- 2.20.1