resourceloader: Remove redundant back-compat in mw.loader.addSource()
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 20 Nov 2015 00:48:01 +0000 (00:48 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 20 Nov 2015 01:19:45 +0000 (01:19 +0000)
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
resources/src/mediawiki/mediawiki.js

index 6995642..414f8e2 100644 (file)
@@ -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.
index db07ec9..b58ce49 100644 (file)
                                /**
                                 * 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;
                                                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;
                                },
 
                                /**