From: Fomafix Date: Mon, 25 Jan 2016 16:31:48 +0000 (+0000) Subject: mediawiki.api.watch: Use formatversion=2 for API requests X-Git-Tag: 1.31.0-rc.0~4532^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=d3a4c8c5ee57e93951fdbba0f16ac835b2e60492;p=lhc%2Fweb%2Fwiklou.git mediawiki.api.watch: Use formatversion=2 for API requests With formatversion=2 the JSON response uses UTF-8 instead of escape sequences with hex for encoding of non-ASCII characters (e.g. "\u00e4" for "รค"). formatversion=2 has a different syntax for boolean values: formatversion=1: "watched": "" formatversion=2: "watched": true Consumers of this API that process the response with response.watched === '' must change this to response.watched === true Change-Id: I087ab538b9400d774f8c2c6a8c0f55a33fab6044 --- diff --git a/resources/src/mediawiki/api/watch.js b/resources/src/mediawiki/api/watch.js index a2ff1292bb..84a234f751 100644 --- a/resources/src/mediawiki/api/watch.js +++ b/resources/src/mediawiki/api/watch.js @@ -26,6 +26,7 @@ var apiPromise = this.postWithToken( 'watch', $.extend( { + formatversion: 2, action: 'watch', titles: $.isArray( pages ) ? pages.join( '|' ) : String( pages ), uselang: mw.config.get( 'wgUserLanguage' ) diff --git a/resources/src/mediawiki/page/watch.js b/resources/src/mediawiki/page/watch.js index b860dbdbb8..f81882b225 100644 --- a/resources/src/mediawiki/page/watch.js +++ b/resources/src/mediawiki/page/watch.js @@ -143,7 +143,7 @@ // Update the "Watch this page" checkbox on action=edit when the // page is watched or unwatched via the tab (bug 12395). - $( '#wpWatchthis' ).prop( 'checked', watchResponse.watched !== undefined ); + $( '#wpWatchthis' ).prop( 'checked', watchResponse.watched === true ); } ) .fail( function () { var cleanTitle, msg, link;