Issue Bug Closed

#98252TCA Default value for times cannot be set

C. Gogolin 09/02/22, 17:54 updated 07/09/24, 12:46

Description

Hi,

In my extension I have created a table which contains a time field. Under Typo3 10.x everything was fine. But when I switched to Typo3 11, the default value was no longer displayed.

Here is the table.sql:

#
# Table structure for table 'tx_participants_domain_model_event' 
# 
CREATE TABLE tx_participants_domain_model_event (
   uid int(11) UNSIGNED DEFAULT '0' NOT NULL auto_increment,
   pid int(11) DEFAULT '0' NOT NULL,
   ,..
   time VARCHAR(10) DEFAULT '19:00:00' NOT NULL,    
   ...
   PRIMARY KEY (uid),
   KEY parent (pid)
);

Here is the TCA configuration: (works for Typo3 10 , but not for Typo3 11)

'time' => [
            'label' => 'LLL:EXT:participants/Resources/Private/Language/locallang_db.xlf:tx_participants_domain_model_event.time',
            'config' => [
                'type' => 'input',
                'renderType' => 'inputDateTime',
                'dbType' => 'time',
                'eval' => 'time',
                'default' => 68400, // 19:00h
                'mode' => 'useOrOverridePlaceholder'
            ]
        ],

Then I did some searching in the core code and found:
./sysext/core/Classes/Database/Query/QueryHelper.php

The method getDateTimeFormats() does not set the reset to zero but 0 for the type “time”.

  /**
     * Returns the date and time formats compatible with the given database.
     *
     * This simple method should probably be deprecated and removed later.
     *
     * @return array
     */
    public static function getDateTimeFormats()
    {
        return [
            'date' => [
                'empty' => '0000-00-00',
                'format' => 'Y-m-d',
                'reset' => null,
            ],
            'datetime' => [
                'empty' => '0000-00-00 00:00:00',
                'format' => 'Y-m-d H:i:s',
                'reset' => null,
            ],
            'time' => [
                'empty' => '00:00:00',
                'format' => 'H:i:s',
                'reset' => 0,
            ],
        ];
    }

This has the consequence that a few steps later my default value is not used. (The fact that I have to patch core again and again can’t be a solution ;-) )
Unfortunately I can’t understand why a 0 and not (as with “date” and “datetime”) zero is specified here. But if I patch the QueryHelper and change 0 to zero, we can use the defaults again.

It would be nice if this is fixed in a timely manner. (Or does this all have to be solved completely different?).

Thanks
Clemens

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.