From 934572cdf7326c82ed76358c9d76de530015498f Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Tue, 30 Apr 2019 19:30:50 +0100 Subject: [PATCH] API: Use formatversion=2 by default V2 has better handling for booleans. Change-Id: I5388bd2cc64ae0c9ed4a185adce1e3bb4cdd92fc --- modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js | 1 - modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js | 6 ++++-- modules/ve-mw/init/ve.init.mw.Target.js | 4 ++++ modules/ve-mw/ui/pages/ve.ui.MWLanguagesPage.js | 1 - modules/ve-mw/ui/widgets/ve.ui.MWEditSummaryWidget.js | 5 ++--- .../ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js b/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js index e823c94f46..1261135cbc 100644 --- a/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js +++ b/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js @@ -303,7 +303,6 @@ titles: titles, lang: mw.config.get( 'wgUserLanguage' ), format: 'json', - formatversion: '2', doNotIgnoreMissingTitles: '1', redirects: '1' } ).done( this.fetchRequestDone.bind( this, titles, specs ) ); diff --git a/modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js b/modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js index d46d16508e..1389f08639 100644 --- a/modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js +++ b/modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js @@ -217,7 +217,8 @@ uselang: mw.config.get( 'wgUserLanguage' ), editintro: uri.query.editintro, preload: options.preload, - preloadparams: options.preloadparams + preloadparams: options.preloadparams, + formatversion: 2 }; // Only request the API to explicitly load the currently visible revision if we're restoring @@ -375,7 +376,8 @@ uselang: mw.config.get( 'wgUserLanguage' ), editintro: uri.query.editintro, preload: options.preload, - preloadparams: options.preloadparams + preloadparams: options.preloadparams, + formatversion: 2 }; // section should never really be undefined, but check just in case diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index d23fc8c64a..9a414bb226 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -658,6 +658,8 @@ ve.init.mw.Target.prototype.getPageName = function () { * @return {mw.Api} API object */ ve.init.mw.Target.prototype.getContentApi = function ( doc, options ) { + options = options || {}; + options.parameters = ve.extendObject( { formatversion: 2 }, options.parameters ); return new mw.Api( options ); }; @@ -671,5 +673,7 @@ ve.init.mw.Target.prototype.getContentApi = function ( doc, options ) { * @return {mw.Api} API object */ ve.init.mw.Target.prototype.getLocalApi = function ( options ) { + options = options || {}; + options.parameters = ve.extendObject( { formatversion: 2 }, options.parameters ); return new mw.Api( options ); }; diff --git a/modules/ve-mw/ui/pages/ve.ui.MWLanguagesPage.js b/modules/ve-mw/ui/pages/ve.ui.MWLanguagesPage.js index b5dd6fac7a..3d610a8ab0 100644 --- a/modules/ve-mw/ui/pages/ve.ui.MWLanguagesPage.js +++ b/modules/ve-mw/ui/pages/ve.ui.MWLanguagesPage.js @@ -169,7 +169,6 @@ ve.ui.MWLanguagesPage.prototype.getAllLanguageItems = function () { // TODO: Detect paging token if results exceed limit ve.init.target.getContentApi().get( { format: 'json', - formatversion: 2, action: 'query', prop: 'langlinks', llprop: 'autonym', diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWEditSummaryWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWEditSummaryWidget.js index f8d0a73fde..21a337cc9c 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWEditSummaryWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWEditSummaryWidget.js @@ -106,14 +106,13 @@ ve.ui.MWEditSummaryWidget.prototype.getSummaries = function () { if ( mw.user.isAnon() ) { this.getSummariesPromise = $.Deferred().resolve( [] ).promise(); } else { - this.getSummariesPromise = new mw.Api().get( { + this.getSummariesPromise = ve.init.target.getLocalApi().get( { action: 'query', list: 'usercontribs', ucuser: mw.user.getName(), ucprop: 'comment|title', uclimit: 500, - format: 'json', - formatversion: 2 + format: 'json' } ).then( function ( response ) { var usedComments = {}, changes = ve.getProp( response, 'query', 'usercontribs' ) || []; diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js index a5df57e234..b378f7de24 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js @@ -105,7 +105,7 @@ ve.ui.MWTemplateTitleInputWidget.prototype.getLookupRequest = function () { xhr = widget.getApi().get( { action: 'templatedata', format: 'json', - formatversion: '2', + formatversion: 2, titles: titles, redirects: !!widget.showRedirects, doNotIgnoreMissingTitles: '1',