jenkins-bot has submitted this change and it was merged. Change subject: ve.dm.MWMediaResourceProvider: Use mw.ForeignApi rather than JSONP ......................................................................
ve.dm.MWMediaResourceProvider: Use mw.ForeignApi rather than JSONP Bug: T143279 Depends-On: Ic93d733cb9e1b1d7301f8975c68ab7ded778845a Depends-On: I24c2819ec2adcab468f961c5c46b31c331324567 (for CA wikis) Depends-On: I372e7bdff35400287b3d961da979d6f094d13bd9 (for CA wikis) Change-Id: I14a1e5c9956d1b425eaacdf358db384df3be8115 --- M modules/ve-mw/dm/models/ve.dm.MWMediaResourceProvider.js 1 file changed, 8 insertions(+), 22 deletions(-) Approvals: Jforrester: Looks good to me, but someone else must approve Esanders: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/ve-mw/dm/models/ve.dm.MWMediaResourceProvider.js b/modules/ve-mw/dm/models/ve.dm.MWMediaResourceProvider.js index 8d24a32..7f37105 100644 --- a/modules/ve-mw/dm/models/ve.dm.MWMediaResourceProvider.js +++ b/modules/ve-mw/dm/models/ve.dm.MWMediaResourceProvider.js @@ -27,25 +27,13 @@ this.isLocal = config.local !== undefined; if ( this.isLocal ) { - this.setAjaxSettings( { - url: mw.util.wikiScript( 'api' ), - // If the url is local use json - dataType: 'json' - } ); + this.setAPIurl( mw.util.wikiScript( 'api' ) ); } else { - this.setAjaxSettings( { - // If 'apiurl' is set, use that. Otherwise, build the url - // from scriptDirUrl and /api.php suffix - url: this.getAPIurl() || ( this.scriptDirUrl + '/api.php' ), - // If the url is not the same origin use jsonp - dataType: 'jsonp', - // JSON-P requests are not cached by default and get a &_=random trail. - // While setting cache=true will still bypass cache in most case due to the - // callback parameter, at least drop the &_=random trail which triggers - // an API warning (invalid parameter). - cache: true - } ); + // If 'apiurl' is set, use that. Otherwise, build the url + // from scriptDirUrl and /api.php suffix + this.setAPIurl( this.getAPIurl() || ( this.scriptDirUrl + '/api.php' ) ); } + this.siteInfoPromise = null; this.thumbSizes = []; this.imageSizes = []; @@ -180,17 +168,15 @@ * the fetched data. */ ve.dm.MWMediaResourceProvider.prototype.fetchAPIresults = function ( howMany ) { - var xhr, - ajaxOptions = {}, + var xhr, api, provider = this; if ( !this.isValid() ) { return $.Deferred().reject().promise( { abort: $.noop } ); } - ajaxOptions = this.getAjaxSettings(); - - xhr = new mw.Api().get( $.extend( {}, this.getStaticParams(), this.getUserParams(), this.getContinueData( howMany ) ), ajaxOptions ); + api = this.isLocal ? new mw.Api() : new mw.ForeignApi( this.getAPIurl(), { anonymous: true } ); + xhr = api.get( $.extend( {}, this.getStaticParams(), this.getUserParams(), this.getContinueData( howMany ) ) ); return xhr .then( function ( data ) { var page, newObj, raw, -- To view, visit https://gerrit.wikimedia.org/r/309767 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I14a1e5c9956d1b425eaacdf358db384df3be8115 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits