diff --git a/VisualEditor.php b/VisualEditor.php index 85fbdd32ec..90e0d637fd 100644 --- a/VisualEditor.php +++ b/VisualEditor.php @@ -204,6 +204,7 @@ $wgResourceModules += array( // Messages needed by VE in init phase only (rest go below) 'visualeditor-loadwarning', 'visualeditor-loadwarning-token', + 'visualeditor-timeout', 'visualeditor-notification-created', 'visualeditor-notification-restored', 'visualeditor-notification-saved', diff --git a/modules/ve-mw/i18n/en.json b/modules/ve-mw/i18n/en.json index dbf7513de2..11ff60457c 100644 --- a/modules/ve-mw/i18n/en.json +++ b/modules/ve-mw/i18n/en.json @@ -158,6 +158,7 @@ "visualeditor-linkinspector-suggest-redirect-page": "{{PLURAL:$1|Redirect page|Redirect pages}}", "visualeditor-loadwarning": "Error loading data from server: $1. Would you like to retry?", "visualeditor-loadwarning-token": "Error loading edit token from server: $1. Would you like to retry?", + "visualeditor-timeout":"It looks like full editing is currently unavailable; would you like to edit in source mode instead?", "visualeditor-mainnamespacepagelink": "Project:Main namespace", "visualeditor-media-input-placeholder": "Search for media", "visualeditor-meta-tool": "Options", diff --git a/modules/ve-mw/i18n/qqq.json b/modules/ve-mw/i18n/qqq.json index e71cadeb4a..2c293fe480 100644 --- a/modules/ve-mw/i18n/qqq.json +++ b/modules/ve-mw/i18n/qqq.json @@ -163,6 +163,7 @@ "visualeditor-linkinspector-suggest-redirect-page": "Label for suggested redirect pages in the link inspector. Parameters:\n* $1 - number of redirect pages, used for plural\n{{Identical|Redirect page}}", "visualeditor-loadwarning": "Text (JavaScript confirm()) shown when the editor fails to load properly.\n\nParameters:\n* $1 - the error message from the server, in English. e.g. \"parsoidserver-http-bad-status: 404\"", "visualeditor-loadwarning-token": "Text (JavaScript confirm()) shown when the editor fails to load properly.\n\nParameters:\n* $1 - the error message from the server.", + "visualeditor-timeout":"Text (JavaScript confirm()) shown when the editor fails to load properly due to a 504 Gateway Timeout error.", "visualeditor-mainnamespacepagelink": "Name of a page describing the main namespace (NS0) in this project.\n{{doc-important|Do not translate \"Project\"; it is automatically converted to the wiki's project namespace.}}", "visualeditor-media-input-placeholder": "Place holder text for media search input", "visualeditor-meta-tool": "Text of tool in the toolbar the lets users set categories, language links and other page settings.\n{{Identical|Options}}", diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js index d90bd2c082..def58298ac 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js @@ -315,10 +315,19 @@ ve.init.mw.ViewPageTarget.prototype.onLoadError = function ( jqXHR, status ) { // The response.status check here is to catch aborts triggered by navigation away from the page if ( status !== 'abort' && - ( !jqXHR || jqXHR.status !== 0 ) && + ( !jqXHR || ( jqXHR.status !== 0 && jqXHR.status !== 504 ) ) && confirm( ve.msg( 'visualeditor-loadwarning', status ) ) ) { this.load(); + } else if ( + jqXHR && jqXHR.status === 504 && + confirm( ve.msg( 'visualeditor-timeout' ) ) + ) { + if ( 'veaction' in this.currentUri.query ) { + delete this.currentUri.query.veaction; + } + this.currentUri.query.action = 'edit'; + window.location.href = this.currentUri.toString(); } else { this.activating = false; // User interface changes