Bug #99985
closedDataHandler: transOrigDiffSourceField not written on translation initialization
100%
Description
When creating a translation, DataHandler copies the record and adds some defaults from original source.
During copying, method fillInFieldArray writes correct data to
$originalLanguage_diffStorage.
Unfortunately, the original content from transOrigDiffSourceField is copied to the $fieldArray. This is useful for history/undo, as described later, but with this behaviour it's not possible to detect changes from source in translation, when translation record is only created and not saved again. A save after creation will fill in diffsource correctly.
To allow adding the diffsource to newly created records without changing the other behaviour, it should managed, that the if-construct checking the write allowed, should check for
strpos((string)$id, 'NEW') !== false
too.
I tested with following setups, all the same behaviour:
- php 7.4
- nginx
Affected TYPO3 versions:
- 9 ELTS
- 10 old LTS
- 11 LTS
untested, but should be affected, too:
- v12
I guess, this part should be changed
// Add diff-storage information:
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);
}
to this
// Add diff-storage information:
if (
$diffStorageFlag
&& (
!array_key_exists($GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField'], $fieldArray)
|| strpos((string)$id, 'NEW') !== false
)
) {
// 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);
}