jenkins-bot has submitted this change and it was merged. 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, 15 insertions(+), 15 deletions(-) Approvals: Ricordisamoa: Looks good to me, but someone else must approve TheDJ: Looks good to me, approved jenkins-bot: Verified 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..b4ff40a 100644 --- a/resources/src/mediawiki/api.js +++ b/resources/src/mediawiki/api.js @@ -52,7 +52,7 @@ promises[ defaultOptions.ajax.url ] = {}; $.each( mw.user.tokens.get(), function ( key, value ) { // This requires #getToken to use the same key as user.tokens. - // Format: token-type + "Token" (eg. editToken, patrolToken, watchToken). + // Format: token-type + "Token" (eg. csrfToken, patrolToken, watchToken). promises[ defaultOptions.ajax.url ][ key ] = $.Deferred() .resolve( value ) .promise( { abort: function () {} } ); @@ -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..60276cd 100644 --- a/resources/src/mediawiki/api/edit.js +++ b/resources/src/mediawiki/api/edit.js @@ -6,7 +6,7 @@ $.extend( mw.Api.prototype, { /** - * Post to API with edit token. If we have no token, get one and try to post. + * Post to API with csrf token. If we have no token, get one and try to post. * If we have a cached token try using that, and if it fails, blank out the * cached token and start over. * @@ -15,18 +15,18 @@ * @return {jQuery.Promise} See #post */ postWithEditToken: function ( params, ajaxOptions ) { - return this.postWithToken( 'edit', params, ajaxOptions ); + return this.postWithToken( 'csrf', params, ajaxOptions ); }, /** - * API helper to grab an edit token. + * API helper to grab a csrf token. * * @return {jQuery.Promise} * @return {Function} return.done * @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..3a959a3 100644 --- a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js +++ b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js @@ -102,9 +102,9 @@ var api = new mw.Api(), test = this; - // Get editToken for local wiki, this should not make + // Get csrfToken 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: merged Gerrit-Change-Id: I1587f66bd9e5cdb8cc24cf68eced1d28ae22f44e Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> Gerrit-Reviewer: Edokter <er...@darcoury.nl> Gerrit-Reviewer: Fomafix Gerrit-Reviewer: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Ricordisamoa <ricordisa...@openmailbox.org> Gerrit-Reviewer: TheDJ <hartman.w...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits