Issue Bug Closed

#105966Backend::getPlainValue() generates invalid values for null dates

Alexander Schnitzler 01/20/25, 12:57 updated 08/12/25, 14:35

Description

https://review.typo3.org/c/Packages/TYPO3.CMS/+/83839 introduced a regression when using nullable \DateTime properties in entities being stored as DATETIME in the database.

Prior to that patch, Backend::getPlainValue() directly returned the incoming null, now it is converted to an invalid string value of 0000-00-00

If 0000-00-00 is a valid value for database engines is an interesting question but not the issue here. Most probably it’s not because such a value is considered invalid during reconstitution of persisted entities as seen in \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::mapDateTime() where an incoming value 0000-00-00 is cast to null.

A solution here should be to check if the property allows null. Regardless of the dbType and the TCA, Extbase should early return the given null.

Reviews 2