Gerrit Patch Uploader has uploaded a new change for review. https://gerrit.wikimedia.org/r/283473
Change subject: mw.Api: Replace deprecated token names by 'csrf' ...................................................................... mw.Api: Replace deprecated token names by 'csrf' Since 65077ede the deprecated token names like 'edit' or 'options' generate a warning. Change-Id: I1587f66bd9e5cdb8cc24cf68eced1d28ae22f44e --- M resources/src/mediawiki.action/mediawiki.action.edit.stash.js M resources/src/mediawiki/api.js M resources/src/mediawiki/api/edit.js M resources/src/mediawiki/api/options.js M resources/src/mediawiki/api/upload.js M tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js 6 files changed, 11 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/73/283473/1 diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.stash.js b/resources/src/mediawiki.action/mediawiki.action.edit.stash.js index abe912d..20bfa0e 100644 --- a/resources/src/mediawiki.action/mediawiki.action.edit.stash.js +++ b/resources/src/mediawiki.action/mediawiki.action.edit.stash.js @@ -44,7 +44,7 @@ pending.abort(); } - api.getToken( 'edit' ).then( stashEdit ); + api.getToken( 'csrf' ).then( stashEdit ); } function onKeyPress( e ) { diff --git a/resources/src/mediawiki/api.js b/resources/src/mediawiki/api.js index 3bc0ad3..cc61fa2 100644 --- a/resources/src/mediawiki/api.js +++ b/resources/src/mediawiki/api.js @@ -274,7 +274,7 @@ * If we have a cached token try using that, and if it fails, blank out the * cached token and start over. For example to change an user option you could do: * - * new mw.Api().postWithToken( 'options', { + * new mw.Api().postWithToken( 'csrf', { * action: 'options', * optionname: 'gender', * optionvalue: 'female' diff --git a/resources/src/mediawiki/api/edit.js b/resources/src/mediawiki/api/edit.js index 22affb1..10ae626 100644 --- a/resources/src/mediawiki/api/edit.js +++ b/resources/src/mediawiki/api/edit.js @@ -15,7 +15,7 @@ * @return {jQuery.Promise} See #post */ postWithEditToken: function ( params, ajaxOptions ) { - return this.postWithToken( 'edit', params, ajaxOptions ); + return this.postWithToken( 'csrf', params, ajaxOptions ); }, /** @@ -26,7 +26,7 @@ * @return {string} return.done.token Received token. */ getEditToken: function () { - return this.getToken( 'edit' ); + return this.getToken( 'csrf' ); }, /** diff --git a/resources/src/mediawiki/api/options.js b/resources/src/mediawiki/api/options.js index bd6fa06..0af2a75 100644 --- a/resources/src/mediawiki/api/options.js +++ b/resources/src/mediawiki/api/options.js @@ -54,7 +54,7 @@ } } else { if ( value !== null ) { - deferreds.push( this.postWithToken( 'options', { + deferreds.push( this.postWithToken( 'csrf', { formatversion: 2, action: 'options', optionname: name, @@ -62,7 +62,7 @@ } ) ); } else { // Omitting value resets the option - deferreds.push( this.postWithToken( 'options', { + deferreds.push( this.postWithToken( 'csrf', { formatversion: 2, action: 'options', optionname: name @@ -72,7 +72,7 @@ } if ( grouped.length ) { - deferreds.push( this.postWithToken( 'options', { + deferreds.push( this.postWithToken( 'csrf', { formatversion: 2, action: 'options', change: grouped diff --git a/resources/src/mediawiki/api/upload.js b/resources/src/mediawiki/api/upload.js index a6a0d8c..3c8b3f6 100644 --- a/resources/src/mediawiki/api/upload.js +++ b/resources/src/mediawiki/api/upload.js @@ -204,7 +204,7 @@ deferred.reject( 'ok-but-empty', 'No response from API on upload attempt.' ); } else if ( result.error ) { if ( result.error.code === 'badtoken' ) { - api.badToken( 'edit' ); + api.badToken( 'csrf' ); } deferred.reject( result.error.code, result ); diff --git a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js index 520db42..4765d09 100644 --- a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js +++ b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js @@ -104,7 +104,7 @@ // Get editToken for local wiki, this should not make // a request as it should be retrieved from mw.user.tokens. - return api.getToken( 'edit' ) + return api.getToken( 'csrf' ) .then( function ( token ) { assert.ok( token.length, 'Got a token' ); }, function ( err ) { @@ -285,7 +285,7 @@ this.server.respond( [ 200, { 'Content-Type': 'application/json' }, '{ "example": "quux" }' ] ); - return api.postWithToken( 'edit', + return api.postWithToken( 'csrf', { action: 'example' }, { headers: { @@ -296,7 +296,7 @@ .then( function () { assert.equal( test.server.requests[ 0 ].requestHeaders[ 'X-Foo' ], 'Bar', 'Header sent' ); - return api.postWithToken( 'edit', + return api.postWithToken( 'csrf', { action: 'example' }, function () { assert.ok( false, 'This parameter cannot be a callback' ); -- To view, visit https://gerrit.wikimedia.org/r/283473 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1587f66bd9e5cdb8cc24cf68eced1d28ae22f44e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits