mediawiki.api.watch: Fix promise return value format
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 10 Mar 2014 11:01:04 +0000 (12:01 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Mon, 10 Mar 2014 17:49:29 +0000 (18:49 +0100)
Follow-up to Ic77b546c.

Bug: 62422
Change-Id: I2ac9e0da0f1c825e1cefd98d21406fcb089c0827

resources/mediawiki.api/mediawiki.api.watch.js

index fbfe27d..5a24247 100644 (file)
@@ -8,12 +8,14 @@
         * @private
         * @context mw.Api
         *
-        * @param {string|mw.Title|string[]|mw.Title[]} page Full page name or instance of mw.Title or array of pages
+        * @param {string|mw.Title|string[]|mw.Title[]} page Full page name or instance of mw.Title, or an
+        *  array thereof. If an array is passed, the return value passed to the promise will also be an
+        *  array of appropriate objects.
         * @param {Function} [ok] Success callback (deprecated)
         * @param {Function} [err] Error callback (deprecated)
         * @return {jQuery.Promise}
         * @return {Function} return.done
-        * @return {Object} return.done.watch
+        * @return {Object|Object[]} return.done.watch
         * @return {string} return.done.watch.title Full pagename
         * @return {boolean} return.done.watch.watched
         * @return {string} return.done.watch.message Parsed HTML of the confirmational interface message
 
                params = {
                        action: 'watch',
-                       titles: $.isArray( page ) ? page.join( '|' ) : String( page ),
                        token: mw.user.tokens.get( 'watchToken' ),
                        uselang: mw.config.get( 'wgUserLanguage' )
                };
 
+               if ( $.isArray( page ) ) {
+                       params.titles = page.join( '|' );
+               } else {
+                       // The 'title' parameter is deprecated, keeping this for compatibility instead of
+                       // converting to array because the API response changes from object to array of objects
+                       // as well (bug 62422).
+                       params.title = String( page );
+               }
+
                if ( addParams ) {
                        $.extend( params, addParams );
                }