X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fmediawiki.api%2Fmediawiki.api.js;h=749086218eb18d0c4837a0180e018a8a79834a79;hb=10d401dd40e0e8a8e815ee665e0da5fd43aaa85e;hp=cdc67679f4d0ffe705cddadd0368f47ef8672db4;hpb=72c70affc0a4036e74946339268f5ab7abf57eaf;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/mediawiki.api/mediawiki.api.js b/resources/mediawiki.api/mediawiki.api.js index cdc67679f4..749086218e 100644 --- a/resources/mediawiki.api/mediawiki.api.js +++ b/resources/mediawiki.api/mediawiki.api.js @@ -112,11 +112,13 @@ * * @param {Object} parameters * @param {Object} [ajaxOptions] - * @return {jQuery.Promise} Done: API response data. Fail: Error code + * @return {jQuery.Promise} Done: API response data and the jqXHR object. + * Fail: Error code */ ajax: function ( parameters, ajaxOptions ) { var token, apiDeferred = $.Deferred(), + msg = 'Use of mediawiki.api callback params is deprecated. Use the Promise instead.', xhr; parameters = $.extend( {}, this.defaults.parameters, parameters ); @@ -140,10 +142,14 @@ // Backwards compatibility: Before MediaWiki 1.20, // callbacks were done with the 'ok' and 'err' property in ajaxOptions. if ( ajaxOptions.ok ) { + mw.track( 'mw.deprecate', 'api.cbParam' ); + mw.log.warn( msg ); apiDeferred.done( ajaxOptions.ok ); delete ajaxOptions.ok; } if ( ajaxOptions.err ) { + mw.track( 'mw.deprecate', 'api.cbParam' ); + mw.log.warn( msg ); apiDeferred.fail( ajaxOptions.err ); delete ajaxOptions.err; } @@ -160,7 +166,7 @@ } ); } ) // AJAX success just means "200 OK" response, also check API error codes - .done( function ( result ) { + .done( function ( result, textStatus, jqXHR ) { if ( result === undefined || result === null || result === '' ) { apiDeferred.reject( 'ok-but-empty', 'OK response but empty result (check HTTP headers?)' @@ -169,7 +175,7 @@ var code = result.error.code === undefined ? 'unknown' : result.error.code; apiDeferred.reject( code, result ); } else { - apiDeferred.resolve( result ); + apiDeferred.resolve( result, jqXHR ); } } ); @@ -233,12 +239,6 @@ apiPromise = this.get( { action: 'tokens', type: type - }, { - // Due to the API assuming we're logged out if we pass the callback-parameter, - // we have to disable jQuery's callback system, and instead parse JSON string, - // by setting 'jsonp' to false. - // TODO: This concern seems genuine but no other module has it. Is it still - // needed and/or should we pass this by default? } ) .done( function ( data ) { // If token type is not available for this user,