[BUGFIX] l10n_diffsource field can handle empty string and null value 49/57149/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Thu, 7 Jun 2018 09:50:54 +0000 (11:50 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Fri, 8 Jun 2018 11:30:46 +0000 (13:30 +0200)
Depending on DB platform, empty LOB fields can be returned
as NULL value (sqlite) or as empty string (mysql, our postgres
setup, mssql).

The patch adapts a minor detail in DataHandler since isset(null)
is false, but isset('') is true, it uses an array_key_exists()
instead for diff check on transOrigDiffSourceField / l10n_diffsource
field to align these two possible different db return values.

Resolves: #85186
Releases: master
Change-Id: I56c87fa519a0c787515eff403d48ac84e513300d
Reviewed-on: https://review.typo3.org/57149
Reviewed-by: Daniel Siepmann <daniel.siepmann@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Tested-by: Daniel Siepmann <daniel.siepmann@typo3.org>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/core/Classes/DataHandling/DataHandler.php

index b9acaa4..f740a74 100644 (file)
@@ -1464,7 +1464,8 @@ class DataHandler implements LoggerAwareInterface
             && $GLOBALS['TCA'][$table]['ctrl']['languageField']
             && $currentRecord[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0
             && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
-            && (int)$currentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] > 0) {
+            && (int)$currentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] > 0
+        ) {
             $originalLanguageRecord = $this->recordInfo($table, $currentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']], '*');
             BackendUtility::workspaceOL($table, $originalLanguageRecord);
             $originalLanguage_diffStorage = unserialize($currentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']]);
@@ -1568,7 +1569,9 @@ class DataHandler implements LoggerAwareInterface
         }
 
         // Add diff-storage information:
-        if ($diffStorageFlag && !isset($fieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']])) {
+        if ($diffStorageFlag
+            && !array_key_exists($GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField'], $fieldArray)
+        ) {
             // If the field is set it would probably be because of an undo-operation - in which case we should not update the field of course...
             $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']] = serialize($originalLanguage_diffStorage);
         }