Actions
Bug #100649
openExtbase DataMapper doesn't respect datetime when 0 or 0000-00-00 or 0000-00-00 00:00:00 or 00:00:00
Status:
New
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2023-04-18
Due date:
% Done:
0%
Estimated time:
TYPO3 Version:
11
PHP Version:
8.1
Tags:
Complexity:
Is Regression:
Sprint Focus:
Stabilization Sprint
Description
When using TCA to set an input to datetime or time, like in the documentation (https://docs.typo3.org/m/typo3/reference-tca/11.5/en-us/ColumnsConfig/Type/Input/DateTime/Properties/DbType.html#time-picker-stored-in-a-datetime-field)
'synced_at' => [
'config' => [
'type' => 'input',
'dbType' => 'time',
'eval' => 'time,null',
],
],
The "core" part is working fine, you can set your field to null or midnight (00:00:00)
But then this line in extbase (https://github.com/TYPO3/typo3/blob/main/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php#L315) change it to null no matter what, so you cannot know if your time property is not set (null) or midnight (00:00:00)
// Invalid values are converted to NULL
if (empty($value) || $value === '0000-00-00' || $value === '0000-00-00 00:00:00' || $value === '00:00:00') {
return null;
}
A workaround is to change the type of your property to string, and use an extra getter method to make the conversion yourself.
Updated by Sebastien Convers about 1 year ago
- Related to Bug #99847: Null value for time field is ignored in BE added
Actions