From: Bartosz DziewoƄski Date: Mon, 10 Mar 2014 11:01:04 +0000 (+0100) Subject: mediawiki.api.watch: Fix promise return value format X-Git-Tag: 1.31.0-rc.0~16674 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=3fa6c0f3d10f76b17dc9fcb115e8013e1a57985a;p=lhc%2Fweb%2Fwiklou.git mediawiki.api.watch: Fix promise return value format Follow-up to Ic77b546c. Bug: 62422 Change-Id: I2ac9e0da0f1c825e1cefd98d21406fcb089c0827 --- diff --git a/resources/mediawiki.api/mediawiki.api.watch.js b/resources/mediawiki.api/mediawiki.api.watch.js index fbfe27df8e..5a24247897 100644 --- a/resources/mediawiki.api/mediawiki.api.watch.js +++ b/resources/mediawiki.api/mediawiki.api.watch.js @@ -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 @@ -33,11 +35,19 @@ 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 ); }