From d386d76e066b03badd5f6e2e625cef6b3dbc1f46 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 14 Aug 2017 17:13:57 +0200 Subject: [PATCH] Work around module loading issue in `WCF.System.Captcha.getData()` --- wcfsetup/install/files/js/WCF.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index f70c1706db..ee51887997 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -4734,6 +4734,12 @@ WCF.System.ObjectStore = { * Stores captcha callbacks used for captchas in AJAX contexts. */ WCF.System.Captcha = { + /** + * ids of registered captchas + * @var {string[]} + */ + _registeredCaptchas: [], + /** * Adds a callback for a certain captcha. * @@ -4744,6 +4750,8 @@ WCF.System.Captcha = { require(['WoltLabSuite/Core/Controller/Captcha'], function(ControllerCaptcha) { try { ControllerCaptcha.add(captchaID, callback); + + this._registeredCaptchas.push(captchaID); } catch (e) { if (e instanceof TypeError) { @@ -4753,7 +4761,7 @@ WCF.System.Captcha = { // ignore other errors } - }); + }.bind(this)); }, /** @@ -4764,6 +4772,10 @@ WCF.System.Captcha = { getData: function(captchaID) { var returnValue; + if (this._registeredCaptchas.indexOf(captchaID) === -1) { + return returnValue; + } + var ControllerCaptcha = require('WoltLabSuite/Core/Controller/Captcha'); try { returnValue = ControllerCaptcha.getData(captchaID); @@ -4782,11 +4794,13 @@ WCF.System.Captcha = { require(['WoltLabSuite/Core/Controller/Captcha'], function(ControllerCaptcha) { try { ControllerCaptcha.delete(captchaID); + + this._registeredCaptchas.splice(this._registeredCaptchas.indexOf(item), 1); } catch (e) { // ignore errors for unknown captchas } - }); + }.bind(this)); } }; -- 2.20.1