From d3a4c8c5ee57e93951fdbba0f16ac835b2e60492 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Mon, 25 Jan 2016 16:31:48 +0000 Subject: [PATCH] mediawiki.api.watch: Use formatversion=2 for API requests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- resources/src/mediawiki/api/watch.js | 1 + resources/src/mediawiki/page/watch.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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; -- 2.20.1