Project

General

Profile

Bug #98252

Updated by Georg Ringer over 1 year ago

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:  
 <pre><code class="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) 
 ); 
 </code></pre> 


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

 <pre><code class="php"> 
 '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' 
             ] 
         ], 
 </code></pre> 



 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".  

 <pre><code class="php"> 
   /** 
      * 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, 
             ], 
         ]; 
     } 
 </code></pre> 

 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  
  

 Translated with www.DeepL.com/Translator (free version)

Back