#105817The fix for #105666 (streamline null and midnight for dbType datetime) was breaking in some cases, and also ignores the TCA default value for datetime
Description
Updating from 12.4.23 to 12.4.24 led to problems in some of our setups, assumingly due to the change in #105666 (assumingly because there were mutliple changes about date fields and this looks the closest one – due to missing time, we were not able to fully debug this in all details, but these are our initial observations.).
We have a table with SQL columns tx_myext_start datetime default null, the SQL modes strict and NO_ZERO_DATE are enabled (desired and pre-set by the managed hoster).
The TCA looked before like this (trimmed down to the relevant ones):
'type' => 'datetime',
'dbType' => 'datetime',
'default' => 0,
This worked on TYPO3 12.4.23. Submitted empty datetime fields ended up as NULL in the SQL DB.
On 12.4.24 trying to save an empty field, however, this leads to
Invalid datetime format: 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column tx_myext_start
The only thing that reliably helped to mitigate this issue on all our servers/DB engines for 12.4.24 (mix of MySQL, MariaDB), was to set these TCA configs:
'type' => 'datetime',
'dbType' => 'datetime',
'format' => 'datetime',
'default' => null,
'nullable' => true,
Especially 'nullable' => true was the most important one to avoid the SQl error. Isn’t the core-default 'nullable' => true implicitly set if 'dbType' => 'datetime'? At least this is what happened implicitly up to 12.4.23. Did the change in #105666 alter this (intended or unintended)?
Another observation: setting any non-zero/non-null explicit valid default value, like 'default' => '1234-11-11 04:05:06' is completly ignored now, no matter what the nullability is set to. I believe this was also introduced with the change for #105666.