From 1dd7390372641f50b9c7b4d388dd761906ef0722 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 17 Jun 2015 16:12:31 +0100 Subject: [PATCH] mw.loader: Omit private modules from the request queue The server will just deny these modules with an error. We can save that roundtrip by just assuming that state directly. A fair number of these requests hit the server logs primarily from two sources: * Third parties that cache screen-scraped pages from before 2013. The private module wouldn't have existed in the HTML yet. Some scripts aren't cached by them and as such they get a really stretched hybrid. These sometimes end up making requests for modules that no longer exist or indeed modules that have since become private. * Web browsers and proxies that add or modify code on the page which can cause some inline scripts to break. There is no recovery from that in the current system. But falling back to the server is no solution for private modules. (Per T36907; bug 34907) Bug: T101806 Change-Id: If8780db1410dd9ca31b3c1c19a6381a58663edab --- resources/src/mediawiki/mediawiki.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index ec3c0c3a25..a815c99a82 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -1357,7 +1357,16 @@ $.each( dependencies, function ( idx, module ) { var state = mw.loader.getState( module ); + // Only queue modules that are still in the initial 'registered' state + // (not ones already loading, ready or error). if ( state === 'registered' && $.inArray( module, queue ) === -1 ) { + // Private modules must be embedded in the page. Don't bother queuing + // these as the server will deny them anyway (T101806). + if ( registry[module].group === 'private' ) { + registry[module].state = 'error'; + handlePending( module ); + return; + } queue.push( module ); if ( async ) { registry[module].async = true; -- 2.20.1