Item14265: NatEdit plugin leaves UI blocked after some save errors
Priority: Normal
Current State: Closed
Released In: 2.1.3
Target Release: patch
Applies To: Extension
Component: NatEditPlugin
Branches: Release02x01 master
In some circumstances, the
NatEditPlugin's save AJAX calls may not complete successfully, but also may not receive a proper AJAX response. (Possible cases are network anomalies or, as I can reliably reproduce, the timeout of an SSO session cookie maintained by an Apache module I have in front of Foswiki.)
If this happens, clicking on the "Save and Continue" button leaves the "Saving...." modal message in the page and fails to display an error. I've tracked the problem to the ajaxSubmit call at line 912 of the query.natedit.js script. The error handler assumes xhr.responseText exists, and if it does not the script aborts. Similar code appears in the preview button handler. Testing for the presence of responseText before use works around this problem. The following patch also enhances the error message when no detailed message is available:
--- jquery.natedit.uncompressed.js.bak 2017-01-12 15:39:46.000000000 -0500
+++ jquery.natedit.uncompressed.js 2017-01-13 11:18:25.666957772 -0500
@@ -919,7 +919,10 @@
});
},
error: function(xhr, textStatus, errorThrown) {
- var message = self.extractErrorMessage(xhr.responseText) || textStatus;
+ var message = xhr.responseText ? self.extractErrorMessage(xhr.responseText) : textStatus;
+ if (message == "error") {
+ message = "Error: save failed. Please save your content locally and reload this page.";
+ }
self.showMessage("error", message);
},
complete: function(xhr, textStatus) {
@@ -969,7 +972,10 @@
});
},
error: function(xhr, textStatus, errorThrown) {
- var message = self.extractErrorMessage(xhr.responseText) || textStatus;
+ var message = xhr.responseText ? self.extractErrorMessage(xhr.responseText) : textStatus;
+ if (message == "error") {
+ message = "Error: save failed. Please save your content locally and reload this page.";
+ }
$.unblockUI();
self.showMessage("error", message);
},
--
PaulMerchantJr
Michael - Is this okay for 2.1.3?
--
GeorgeClark - 15 Jan 2017
Fixed it somewhat differently without duplicating the logic and the error message.
--
MichaelDaum - 16 Jan 2017
Terrific, thanks!
--
PaulMerchantJr - 17 Jan 2017
--
MichaelDaum - 17 Jan 2017