From 13d9c4582f7b2e1b2f2050a2e0704f5aabbc9cb2 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 20 Nov 2015 00:48:01 +0000 Subject: [PATCH] resourceloader: Remove redundant back-compat in mw.loader.addSource() Follows-up e103ba265b. This method doesn't need to be backward-compatible as this is already normalised server-side. When upgrading from before MediaWiki 1.24 the startup response will change to the new format and also inline a request to the newer version of mediawiki.js. Also update method documentation to be up to date and remove spurious return statements that aren't used. Change-Id: I03d1b5666fcddedaa46ecf878ee7636042a5e3be --- includes/resourceloader/ResourceLoader.php | 2 ++ resources/src/mediawiki/mediawiki.js | 17 +++++------------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 6995642214..414f8e2a63 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -435,6 +435,8 @@ class ResourceLoader implements LoggerAwareInterface { /** * Add a foreign source of modules. * + * Source IDs are typically the same as the Wiki ID or database name (e.g. lowercase a-z). + * * @param array|string $id Source ID (string), or array( id1 => loadUrl, id2 => loadUrl, ... ) * @param string|array $loadUrl load.php url (string), or array with loadUrl key for * backwards-compatibility. diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index db07ec9c0e..b58ce493d7 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -1687,14 +1687,13 @@ /** * Register a source. * - * The #work method will use this information to split up requests by source. + * The #work() method will use this information to split up requests by source. * * mw.loader.addSource( 'mediawikiwiki', '//www.mediawiki.org/w/load.php' ); * - * @param {string} id Short string representing a source wiki, used internally for - * registered modules to indicate where they should be loaded from (usually lowercase a-z). - * @param {Object|string} loadUrl load.php url, may be an object for backwards-compatibility - * @return {boolean} + * @param {string|Object} id Source ID, or object mapping ids to load urls + * @param {string} loadUrl Url to a load.php end point + * @throws {Error} If source id is already registered */ addSource: function ( id, loadUrl ) { var source; @@ -1703,20 +1702,14 @@ for ( source in id ) { mw.loader.addSource( source, id[ source ] ); } - return true; + return; } if ( hasOwn.call( sources, id ) ) { throw new Error( 'source already registered: ' + id ); } - if ( typeof loadUrl === 'object' ) { - loadUrl = loadUrl.loadScript; - } - sources[ id ] = loadUrl; - - return true; }, /** -- 2.20.1