[BUGFIX] Use TSConfig defaults for DataHandler 53/58453/5
authorGuido Schmechel <guido.schmechel@brandung.de>
Sat, 29 Sep 2018 11:49:59 +0000 (13:49 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 7 Mar 2019 21:10:50 +0000 (22:10 +0100)
Now the DataHandler observes the default values set in TsConfig. Example:

TCAdefaults.pages {
    # set page to visible
    hidden = 0
}

Resolves: #59383
Releases: master, 9.5
Change-Id: I51e5d07e4e9a9457135bb9af88868cd52af373d7
Reviewed-on: https://review.typo3.org/c/58453
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/backend/Classes/Controller/EditDocumentController.php
typo3/sysext/backend/Classes/Controller/Page/NewMultiplePagesController.php
typo3/sysext/backend/Classes/Controller/SimpleDataHandlerController.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php

index e14279e..513cf4a 100644 (file)
@@ -516,11 +516,6 @@ class EditDocumentController
 
         $tce->setControl($parsedBody['control'] ?? $queryParams['control'] ?? []);
 
-        // Set default values specific for the user
-        $TCAdefaultOverride = $beUser->getTSConfig()['TCAdefaults.'] ?? null;
-        if (is_array($TCAdefaultOverride)) {
-            $tce->setDefaultsFromUserTS($TCAdefaultOverride);
-        }
         // Set internal vars
         if (isset($beUser->uc['neverHideAtCopy']) && $beUser->uc['neverHideAtCopy']) {
             $tce->neverHideAtCopy = 1;
index 07ab16b..684b18e 100644 (file)
@@ -181,12 +181,6 @@ class NewMultiplePagesController
         if (!empty($commandArray)) {
             $pagesCreated = true;
             $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
-            // Set default TCA values specific for the user
-            $backendUser = $this->getBackendUser();
-            $tcaDefaultOverride = $backendUser->getTSConfig()['TCAdefaults.'] ?? null;
-            if (is_array($tcaDefaultOverride)) {
-                $dataHandler->setDefaultsFromUserTS($tcaDefaultOverride);
-            }
             $dataHandler->start($commandArray, []);
             $dataHandler->process_datamap();
             BackendUtility::setUpdateSignal('updatePageTree');
index cb6491b..35b4198 100644 (file)
@@ -197,10 +197,6 @@ class SimpleDataHandlerController
         if ($beUser->uc['neverHideAtCopy']) {
             $this->tce->neverHideAtCopy = 1;
         }
-        $TCAdefaultOverride = $beUser->getTSConfig()['TCAdefaults.'] ?? null;
-        if (is_array($TCAdefaultOverride)) {
-            $this->tce->setDefaultsFromUserTS($TCAdefaultOverride);
-        }
         // Reverse order.
         if ($this->flags['reverseOrder']) {
             $this->tce->reverseOrder = 1;
index ad797d1..489efd9 100644 (file)
@@ -645,6 +645,13 @@ class DataHandler implements LoggerAwareInterface
         if ($this->BE_USER->uc['recursiveDelete']) {
             $this->deleteTree = 1;
         }
+
+        // Get default values from user TSConfig
+        $tcaDefaultOverride = $this->BE_USER->getTSConfig()['TCAdefaults.'] ?? null;
+        if (is_array($tcaDefaultOverride)) {
+            $this->setDefaultsFromUserTS($tcaDefaultOverride);
+        }
+
         // Initializing default permissions for pages
         $defaultPermissions = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPermissions'];
         if (isset($defaultPermissions['user'])) {
@@ -878,7 +885,7 @@ class DataHandler implements LoggerAwareInterface
                 $old_pid_value = '';
                 // Is it a new record? (Then Id is a string)
                 if (!MathUtility::canBeInterpretedAsInteger($id)) {
-                    // Get a fieldArray with default values
+                    // Get a fieldArray with tca default values
                     $fieldArray = $this->newFieldArray($table);
                     // A pid must be set for new records.
                     if (isset($incomingFieldArray['pid'])) {