Bug #91838
closedTCA l10n_mode="exclude" with TCA config dbType='datetime' set wrong timezone in translated records
0%
Description
For TCA fields of the type "datetime" where "l10n_mode=exclude" is set, the DB field (which is already in UTC format) is converted to UTC again when the translated data records are synchronized with the original data record. The reason is that the time zone information is missing in the database.
Example:¶
TCA Configuration:
'date' => [
'exclude' => true,
'label' => 'date',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'dbType' => 'datetime',
'eval' => 'datetime,required'
],
'l10n_mode' => 'exclude',
],
Mysql Field
date datetime,
LocalConfiguration:
'SYS' => [
'phpTimeZone' => 'Europe/Berlin',
'serverTimeZone' => 'Europe/Berlin',
],
If I save the field with the value " 14:00 03-09-2020" then this date is sent in the format "2020-09-03T*14:00*:00Z" (I think the time zone is already set correctly in the frontend) and stored in the database with the date "2020-09-03 14:00 :00". The correct date will also be saved correctly in the translated data set.
But when I edit and save the translated dataset, the date of the original dataset "2020-09-03 14:00:00" is copied from the database (without time zone). The datahandler converts the date into UTC format and the new "wrong" date "2020-09-03 12:00:00" is written back to the database.
I think it's the same problem as issue #81228
The following patch has worked for me
--- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php
+++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php
@@ -1966,7 +1966,7 @@ protected function checkValueForInput($value, $tcaFieldConf, $table, $id, $realP
// Convert the date/time into a timestamp for the sake of the checks
$emptyValue = $dateTimeFormats[$tcaFieldConf['dbType']]['empty'];
// We store UTC timestamps in the database, which is what getTimestamp() returns.
- $dateTime = new \DateTime($value);
+ $dateTime = new \DateTime($value, new \DateTimeZone('UTC'));
$value = $value === $emptyValue ? null : $dateTime->getTimestamp();
}
}
Updated by Imko Schumacher about 4 years ago
- Related to Bug #89914: Native date (TCA dbType) fields are not properly copied or localized added
Updated by Benni Mack over 1 year ago
- Related to Bug #79249: TCA fields with eval types "time" or "timesec" are incorrectly stored in the database added
Updated by Benni Mack over 1 year ago
- Status changed from New to Closed
I do think this is fixed now, since TYPO3 now uses the exact code snippet in a few versions.
If you feel this is still an issue in v12+, let me know and i will re-open the ticket.