[BUGFIX] JS: Invert dependency definition for FormEngine and Validation 78/52178/2
authorMarkus Klein <markus.klein@typo3.org>
Mon, 27 Mar 2017 13:45:58 +0000 (15:45 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 27 Mar 2017 17:33:35 +0000 (19:33 +0200)
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>
typo3/sysext/backend/Classes/Form/FormResultCompiler.php
typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js
typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js

index 9299f11..ef30cfa 100644 (file)
@@ -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;
 
index a4c9c35..a31066f 100644 (file)
  */
 
 // 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;
                }
index ac9f619..b2c16fa 100644 (file)
@@ -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;
 });