#94699Extbase: DateTimeImmutables won't be stored as UTC
Description
When using a \DateTimeImmutable property and TCA dbType is set to date, time or datetime then the actual value won’t get persisted as UTC in the database.
After the value has been persisted, the value will be read from the database and interpreted as UTC, thus the model will have a wrong \DateTimeImmutable property value.
The issue is caused, by \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::getPlainValue() where timezone will be set to UTC.
The \DateTimeImmutable won’t be updated with the “new” timezone, thus a wrong value will be stored.
- v10.4 LTS https://github.com/TYPO3-CMS/extbase/blob/v10.4.18/Classes/Persistence/Generic/Mapper/DataMapper.php#L752
- v9.5 LTS https://github.com/TYPO3-CMS/extbase/blob/v9.5.28/Classes/Persistence/Generic/Mapper/DataMapper.php#L774
- v8.7 LTS https://github.com/TYPO3-CMS/extbase/blob/v8.7.32/Classes/Persistence/Generic/Mapper/DataMapper.php#L705
- v7.6 LTS https://github.com/TYPO3/typo3/blob/v7.6.32/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php#L703
TYPO3 CMS v11 should not be affected, because the the timezone won’t be altered.
Reviews 1
History 4
-
Moritz Ngo changed description 08/03/21, 16:04
-
Moritz Ngo changed description 08/03/21, 16:26
-
Benjamin Franzke commented and changed status
NewClosed 03/20/25, 13:15 -
Benjamin Franzke changed Duplicates #91240 03/20/25, 13:15
Yes, that’s true it’s broken in version below 11, as this issue was fixed in v11.0 only (as it is quite a drastic change) with the following patch:
> 64053: [BUGFIX] Do not convert native DATETIME values in Extbase | https://review.typo3.org/c/Packages/TYPO3.CMS/+/64053
Thanks for you report anyway!