mediawiki.api.watch: Use formatversion=2 for API requests
authorFomafix <fomafix@googlemail.com>
Mon, 25 Jan 2016 16:31:48 +0000 (16:31 +0000)
committerFomafix <fomafix@googlemail.com>
Wed, 2 Nov 2016 17:24:15 +0000 (18:24 +0100)
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
resources/src/mediawiki/page/watch.js

index a2ff129..84a234f 100644 (file)
@@ -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' )
index b860dbd..f81882b 100644 (file)
 
                                        // 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;