From bfb2290ae3ceaffc783329c0bd54355e3fb38ee3 Mon Sep 17 00:00:00 2001 From: Markus Klein <markus.klein@typo3.org> Date: Mon, 27 Mar 2017 15:45:58 +0200 Subject: [PATCH] [BUGFIX] JS: Invert dependency definition for FormEngine and Validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FormEngineValidation is meant as integral part of FormEngine. The current dependency definition is inverted, such that FormEngine now depends on FormEngineValidation and not the other way around. Note that FormEngineValidation does not need any other feature of FormEngine, so this is safe. This solves a possible race condition with other modules. Releases: master, 7.6 Resolves: #80459 Change-Id: Ie2cb9dd90220b37a98bc8e3ca174fd074488cc8d Reviewed-on: https://review.typo3.org/52178 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Andreas Fernandez <typo3@scripting-base.de> Reviewed-by: Frank Nägler <frank.naegler@typo3.org> Tested-by: Frank Nägler <frank.naegler@typo3.org> Reviewed-by: Kay Strobach <typo3@kay-strobach.de> Tested-by: Kay Strobach <typo3@kay-strobach.de> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Classes/Form/FormResultCompiler.php | 6 ++-- .../Resources/Public/JavaScript/FormEngine.js | 28 +++++++++++-------- .../Public/JavaScript/FormEngineValidation.js | 6 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/typo3/sysext/backend/Classes/Form/FormResultCompiler.php b/typo3/sysext/backend/Classes/Form/FormResultCompiler.php index 9299f116cdc7..ef30cfa5820f 100644 --- a/typo3/sysext/backend/Classes/Form/FormResultCompiler.php +++ b/typo3/sysext/backend/Classes/Form/FormResultCompiler.php @@ -216,10 +216,8 @@ class FormResultCompiler // load the main module for FormEngine with all important JS functions $this->requireJsModules['TYPO3/CMS/Backend/FormEngine'] = 'function(FormEngine) { FormEngine.setBrowserUrl(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')) . '); - }'; - $this->requireJsModules['TYPO3/CMS/Backend/FormEngineValidation'] = 'function(FormEngineValidation) { - FormEngineValidation.setUsMode(' . ($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? '1' : '0') . '); - FormEngineValidation.registerReady(); + FormEngine.Validation.setUsMode(' . ($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? '1' : '0') . '); + FormEngine.Validation.registerReady(); }'; $this->requireJsModules['TYPO3/CMS/Backend/FormEngineReview'] = null; diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js index a4c9c3551bfc..a31066fac18a 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js @@ -21,30 +21,32 @@ */ // add legacy functions to be accessible in the global scope -var setFormValueOpenBrowser - ,setFormValueFromBrowseWin - ,setHiddenFromList - ,setFormValueManipulate - ,setFormValue_getFObj; +var setFormValueOpenBrowser, + setFormValueFromBrowseWin, + setHiddenFromList, + setFormValueManipulate, + setFormValue_getFObj; /** * Module: TYPO3/CMS/Backend/FormEngine */ define(['jquery', + 'TYPO3/CMS/Backend/FormEngineValidation', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity' - ], function ($, Modal, Severity) { + ], function ($, FormEngineValidation, Modal, Severity) { /** * - * @type {{formName: *, openedPopupWindow: null, legacyFieldChangedCb: Function, browserUrl: string}} + * @type {{formName: *, openedPopupWindow: window, legacyFieldChangedCb: Function, browserUrl: string}} * @exports TYPO3/CMS/Backend/FormEngine */ var FormEngine = { - formName: TYPO3.settings.FormEngine.formName - ,openedPopupWindow: null - ,legacyFieldChangedCb: function() { !$.isFunction(TYPO3.settings.FormEngine.legacyFieldChangedCb) || TYPO3.settings.FormEngine.legacyFieldChangedCb(); } - ,browserUrl: '' + Validation: FormEngineValidation, + formName: TYPO3.settings.FormEngine.formName, + openedPopupWindow: null, + legacyFieldChangedCb: function() { !$.isFunction(TYPO3.settings.FormEngine.legacyFieldChangedCb) || TYPO3.settings.FormEngine.legacyFieldChangedCb(); }, + browserUrl: '' }; /** @@ -90,10 +92,12 @@ define(['jquery', exclusiveValues = String(exclusiveValues); var $fieldEl, - $originalFieldEl = $fieldEl = FormEngine.getFieldElement(fieldName), + $originalFieldEl, isMultiple = false, isList = false; + $originalFieldEl = $fieldEl = FormEngine.getFieldElement(fieldName); + if ($originalFieldEl.length === 0 || value === '--div--') { return; } diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js index ac9f619beb1c..b2c16fa374b9 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js @@ -16,7 +16,7 @@ * Contains all JS functions related to TYPO3 TCEforms/FormEngineValidation * @internal */ -define(['jquery', 'TYPO3/CMS/Backend/FormEngine', 'moment'], function ($, FormEngine, moment) { +define(['jquery', 'moment'], function ($, moment) { /** * The main FormEngineValidation object @@ -1040,7 +1040,5 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine', 'moment'], function ($, FormEn FormEngineValidation.initialize(); }; - FormEngine.Validation = FormEngineValidation; - - return FormEngine.Validation; + return FormEngineValidation; }); -- GitLab