From: Fomafix Date: Sun, 17 Apr 2016 11:20:53 +0000 (+0000) Subject: mediawiki.special.upload: Use formatversion=2 for API requests X-Git-Tag: 1.31.0-rc.0~7266^2 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=f4fc65abe1d8d42b99804e2225775641b6ef072f;p=lhc%2Fweb%2Fwiklou.git mediawiki.special.upload: Use formatversion=2 for API requests This simplifies the processing of the response. Change-Id: I2073ec2c017e4d5c5c7f786b45118516feea1aac --- diff --git a/resources/src/mediawiki.special/mediawiki.special.upload.js b/resources/src/mediawiki.special/mediawiki.special.upload.js index 377b1f7ebd..49af809011 100644 --- a/resources/src/mediawiki.special/mediawiki.special.upload.js +++ b/resources/src/mediawiki.special/mediawiki.special.upload.js @@ -65,20 +65,20 @@ title = mw.Title.newFromText( this.nameToCheck, mw.config.get( 'wgNamespaceIds' ).file ); ( new mw.Api() ).get( { + formatversion: 2, action: 'query', // If title is empty, user input is invalid, the API call will produce details about why titles: title ? title.getPrefixedText() : this.nameToCheck, prop: 'imageinfo', - iiprop: 'uploadwarning', - indexpageids: true + iiprop: 'uploadwarning' } ).done( function ( result ) { var resultOut = '', - pageId = result.query.pageids[ 0 ]; - if ( result.query.pages[ pageId ].imageinfo ) { - resultOut = result.query.pages[ pageId ].imageinfo[ 0 ].html; - } else if ( result.query.pages[ pageId ].invalidreason ) { - resultOut = mw.html.escape( result.query.pages[ pageId ].invalidreason ); + page = result.query.pages[ 0 ]; + if ( page.imageinfo ) { + resultOut = page.imageinfo[ 0 ].html; + } else if ( page.invalidreason ) { + resultOut = mw.html.escape( page.invalidreason ); } $spinnerDestCheck.remove(); uploadWarning.processResult( resultOut, uploadWarning.nameToCheck ); @@ -123,6 +123,7 @@ $spinnerLicense = $.createSpinner().insertAfter( '#wpLicense' ); ( new mw.Api() ).get( { + formatversion: 2, action: 'parse', text: '{{' + license + '}}', title: $( '#wpDestFile' ).val() || 'File:Sample.jpg', @@ -135,7 +136,7 @@ }, processResult: function ( result, license ) { - this.responseCache[ license ] = result.parse.text[ '*' ]; + this.responseCache[ license ] = result.parse.text; this.showPreview( this.responseCache[ license ] ); },