From 1dab32babef3a841d4281bed6874cc810a3c36bf Mon Sep 17 00:00:00 2001
From: Hannes Lau <office@hanneslau.de>
Date: Fri, 22 Jan 2016 18:51:20 +0100
Subject: [PATCH] [BUGFIX] DataHandler: Use the updated field to determine
 record type
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Use the new, updated field values of the current record, to determine
its type value. This allows to pick the correct RTE configuration
for new records with non-default types.

Fixes: #72898
Releases: master, 7.6
Change-Id: If519a9c9357034977ede40d7b709a7d83a3e92c8
Reviewed-on: https://review.typo3.org/46162
Reviewed-by: Sascha Egerer <sascha@sascha-egerer.de>
Reviewed-by: Eugen Lang <laeu1011+gerrit@gmail.com>
Tested-by: Eugen Lang <laeu1011+gerrit@gmail.com>
Tested-by: Jonas Götze <jonnsn@gmail.com>
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
---
 typo3/sysext/core/Classes/DataHandling/DataHandler.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php
index 56b8ef08437e..f6f1b0fefd18 100644
--- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php
+++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php
@@ -1521,7 +1521,7 @@ class DataHandler
             $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']] = serialize($originalLanguage_diffStorage);
         }
         // Checking for RTE-transformations of fields:
-        $types_fieldConfig = BackendUtility::getTCAtypes($table, $currentRecord);
+        $types_fieldConfig = BackendUtility::getTCAtypes($table, $this->checkValue_currentRecord);
         $theTypeString = null;
         if (is_array($types_fieldConfig)) {
             foreach ($types_fieldConfig as $vconf) {
@@ -1533,12 +1533,12 @@ class DataHandler
                 // Look for transformation flag:
                 if ((string)$incomingFieldArray['_TRANSFORM_' . $vconf['field']] === 'RTE') {
                     if ($theTypeString === null) {
-                        $theTypeString = BackendUtility::getTCAtypeValue($table, $currentRecord);
+                        $theTypeString = BackendUtility::getTCAtypeValue($table, $this->checkValue_currentRecord);
                     }
                     $RTEsetup = $this->BE_USER->getTSConfig('RTE', BackendUtility::getPagesTSconfig($tscPID));
                     $thisConfig = BackendUtility::RTEsetup($RTEsetup['properties'], $table, $vconf['field'], $theTypeString);
                     $fieldArray[$vconf['field']] = $this->transformRichtextContentToDatabase(
-                        $fieldArray[$vconf['field']], $table, $vconf['field'], $vconf['spec'], $thisConfig, $currentRecord['pid']
+                        $fieldArray[$vconf['field']], $table, $vconf['field'], $vconf['spec'], $thisConfig, $this->checkValue_currentRecord['pid']
                     );
                 }
             }
-- 
GitLab