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

Change subject: Prevent endless error loop if falling back to wikitext (after a 
load failure) fails.
......................................................................


Prevent endless error loop if falling back to wikitext (after a load failure) 
fails.

Change-Id: Id48fa13a33aee9fabf857d20a75d26463c329f44
---
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
1 file changed, 9 insertions(+), 0 deletions(-)

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



diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js 
b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
index 17082a3..2f0577c 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
@@ -317,6 +317,7 @@
        // Parent method
        ve.init.mw.DesktopArticleTarget.super.prototype.loadSuccess.apply( 
this, arguments );
 
+       this.wikitextFallbackLoading = false;
        // Duplicate of this code in ve.init.mw.DesktopArticleTarget.init.js
        if ( $( '#ca-edit' ).hasClass( 'visualeditor-showtabdialog' ) ) {
                $( '#ca-edit' ).removeClass( 'visualeditor-showtabdialog' );
@@ -609,6 +610,13 @@
        // Parent method
        ve.init.mw.DesktopArticleTarget.super.prototype.loadFail.apply( this, 
arguments );
 
+       if ( this.wikitextFallbackLoading ) {
+               // Failed twice now
+               mw.log.warn( 'Failed to fall back to wikitext', errorText, 
error );
+               location.href = target.viewUri.clone().extend( { action: 
'edit', veswitched: 1 } );
+               return;
+       }
+
        // Don't show an error if the load was manually aborted
        // The response.status check here is to catch aborts triggered by 
navigation away from the page
        if (
@@ -650,6 +658,7 @@
                                target.deactivate( true );
                        } else {
                                // TODO: Some sort of progress bar?
+                               target.wikitextFallbackLoading = true;
                                target.switchToWikitextEditor( true, false );
                        }
                } );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id48fa13a33aee9fabf857d20a75d26463c329f44
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <a...@wikimedia.org>
Gerrit-Reviewer: Alex Monk <a...@wikimedia.org>
Gerrit-Reviewer: Esanders <esand...@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