jenkins-bot has submitted this change and it was merged.

Change subject: mw.Target: Removed unreachable badtoken recovery code
......................................................................


mw.Target: Removed unreachable badtoken recovery code

This code caught badtoken errors on load, but we can't get those
any more since the API module was split and we no longer send a token
on load. badtoken handling on save is done in mw.ViewPageTarget.

Bug: 51253
Change-Id: Idb172ee46b7142681d41e593eacd9600b8f11a9a
---
M modules/ve-mw/init/ve.init.mw.Target.js
1 file changed, 4 insertions(+), 82 deletions(-)

Approvals:
  Esanders: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve-mw/init/ve.init.mw.Target.js 
b/modules/ve-mw/init/ve.init.mw.Target.js
index cdd638d..ba82cf4 100644
--- a/modules/ve-mw/init/ve.init.mw.Target.js
+++ b/modules/ve-mw/init/ve.init.mw.Target.js
@@ -93,13 +93,6 @@
  */
 
 /**
- * @event tokenError
- * @param {jqXHR|null} jqXHR
- * @param {string} status Text status message
- * @param {Mixed|null} error HTTP status text
- */
-
-/**
  * @event saveError
  * @param {jqXHR|null} jqXHR
  * @param {string} status Text status message
@@ -169,17 +162,10 @@
                        this, null, 'Invalid response in response from server', 
null
                );
        } else if ( response.error || data.result === 'error' ) {
-               if ( response.error.code === 'badtoken' && !this.retriedToken ) 
{
-                       // Only retry once
-                       this.retriedToken = true;
-                       // Refresh the edit token and try again
-                       this.retryToken();
-               } else {
-                       ve.init.mw.Target.onLoadError.call( this, null,
-                               response.error.code + ': ' + 
response.error.info,
-                               null
-                       );
-               }
+               ve.init.mw.Target.onLoadError.call( this, null,
+                       response.error.code + ': ' + response.error.info,
+                       null
+               );
        } else if ( typeof data.content !== 'string' ) {
                ve.init.mw.Target.onLoadError.call(
                        this, null, 'No HTML content in response from server', 
null
@@ -248,37 +234,6 @@
 };
 
 /**
- * Handle response to a successful edit token refresh request.
- *
- * This method is called within the context of a target instance. If 
successful the token will
- * be stored and load() will be called.
- *
- * @static
- * @method
- * @param {Object} response XHR Response object
- * @param {string} status Text status message
- * @emits tokenError
- */
-ve.init.mw.Target.onToken = function ( response ) {
-       var token = response && response.tokens && response.tokens.edittoken;
-       if ( token ) {
-               this.editToken = token;
-               mw.user.tokens.set( 'editToken', token );
-               this.loading = false; // Otherwise this.load() doesn't do 
anything
-               this.load();
-       } else if ( !response.error ) {
-               ve.init.mw.Target.onTokenError.call(
-                       this, null, 'Invalid response in response from server', 
null
-               );
-       } else {
-               ve.init.mw.Target.onTokenError.call( this, null,
-                       response.error.code + ': ' + response.error.info,
-                       null
-               );
-       }
-};
-
-/**
  * Handle both DOM and modules being loaded and ready.
  *
  * This method is called within the context of a target instance.
@@ -310,21 +265,6 @@
 ve.init.mw.Target.onLoadError = function ( jqXHR, status, error ) {
        this.loading = false;
        this.emit( 'loadError', jqXHR, status, error );
-};
-
-/**
- * Handle an unsuccessful token refresh request.
- *
- * This method is called within the context of a target instance.
- *
- * @param {Object} jqXHR
- * @param {string} status Text status message
- * @param {Mixed} error HTTP status text
- * @emits tokenError
- */
-ve.init.mw.Target.onTokenError = function ( jqXHR, status, error ) {
-       this.loading = false;
-       this.emit( 'tokenError', jqXHR, status, error );
 };
 
 /**
@@ -587,24 +527,6 @@
                'error': ve.bind( ve.init.mw.Target.onLoadError, this )
        } );
        return true;
-};
-
-/**
- * Refresh the edit token, then call load()
- */
-ve.init.mw.Target.prototype.retryToken = function () {
-       $.ajax( {
-               'url': this.apiUrl,
-               'data': {
-                       'action': 'tokens',
-                       'format': 'json'
-               },
-               'dataType': 'json',
-               'type': 'GET',
-               'cache': 'false',
-               'success': ve.bind( ve.init.mw.Target.onToken, this ),
-               'error': ve.bind( ve.init.mw.Target.onTokenError, this )
-       } );
 };
 
 /**

-- 
To view, visit https://gerrit.wikimedia.org/r/76860
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Idb172ee46b7142681d41e593eacd9600b8f11a9a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Esanders <esand...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Trevor Parscal <tpars...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to