resourceloader: Remove redundant filter() in mw.load.load()
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 9 Apr 2019 03:06:38 +0000 (04:06 +0100)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 9 Apr 2019 19:19:53 +0000 (19:19 +0000)
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

index 4c20e9d..22bd014 100644 (file)
                                 *  "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' ) {
                                                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 );
                                },
 
                                /**