Merge "mediawiki.api: Do not cache errors in getToken()"
[lhc/web/wiklou.git] / resources / src / mediawiki.api / mediawiki.api.js
index 5f0b004..4e497c4 100644 (file)
                 *
                 * @param {string} tokenType The name of the token, like options or edit.
                 * @param {Object} params API parameters
+                * @param {Object} [ajaxOptions]
                 * @return {jQuery.Promise} See #post
                 * @since 1.22
                 */
-               postWithToken: function ( tokenType, params ) {
+               postWithToken: function ( tokenType, params, ajaxOptions ) {
                        var api = this;
 
+                       // Do not allow deprecated ok-callback
+                       // FIXME: Remove this check when the deprecated ok-callback is removed in #post
+                       if ( $.isFunction( ajaxOptions ) ) {
+                               ajaxOptions = undefined;
+                       }
+
                        return api.getToken( tokenType ).then( function ( token ) {
                                params.token = token;
-                               return api.post( params ).then(
+                               return api.post( params, ajaxOptions ).then(
                                        // If no error, return to caller as-is
                                        null,
                                        // Error handler
                                                        // Try again, once
                                                        return api.getToken( tokenType ).then( function ( token ) {
                                                                params.token = token;
-                                                               return api.post( params );
+                                                               return api.post( params, ajaxOptions );
                                                        } );
                                                }