From: Tim Düsterhus Date: Thu, 22 Apr 2021 12:39:20 +0000 (+0200) Subject: Fix backwards compatibility of AJAX failure callback X-Git-Tag: 5.4.0_Alpha_1~61 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=df42d11e0e80b65fdf19b62351dbdb9442e62529;p=GitHub%2FWoltLab%2FWCF.git Fix backwards compatibility of AJAX failure callback Fixes #4088 --- diff --git a/ts/WoltLabSuite/Core/Ajax/Request.ts b/ts/WoltLabSuite/Core/Ajax/Request.ts index 9a533ba156..928010c51b 100644 --- a/ts/WoltLabSuite/Core/Ajax/Request.ts +++ b/ts/WoltLabSuite/Core/Ajax/Request.ts @@ -278,7 +278,9 @@ class AjaxRequest { let showError = true; if (typeof options.failure === "function") { - showError = options.failure(data || {}, xhr.responseText || "", xhr, options.data!); + // undefined might be returned by legacy callbacks and must be treated as 'true'. + const result = options.failure(data || {}, xhr.responseText || "", xhr, options.data!) as boolean | undefined; + showError = result !== false; } if (options.ignoreError !== true && showError) { diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js index c00e0b6722..37da9d0885 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js @@ -233,7 +233,9 @@ define(["require", "exports", "tslib", "./Status", "../Core", "../Dom/Change/Lis } let showError = true; if (typeof options.failure === "function") { - showError = options.failure(data || {}, xhr.responseText || "", xhr, options.data); + // undefined might be returned by legacy callbacks and must be treated as 'true'. + const result = options.failure(data || {}, xhr.responseText || "", xhr, options.data); + showError = result !== false; } if (options.ignoreError !== true && showError) { const html = this.getErrorHtml(data, xhr);