Project

General

Profile

Actions

Bug #92900

open

Unable to store "epoch start" on native datetime fields with dbtype

Added by Imko Schumacher over 3 years ago. Updated 10 months ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
-
Start date:
2020-11-21
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
TCA dbtype datetime
Complexity:
Is Regression:
Sprint Focus:

Description

The datetime input 00:00 01-01-1970 (special value - start of unix epoch, timestamp 0) gets saved as default value 0000-00-00 00:00:00.

Prerequisite

- testet on master(9ded7c21f126627b090b4f13715f03d3c57ebe30), 10.4.9 and seems to be present in older versions

TCA configuration:

'columns' => [
    'mydatetime' => [
        'config' => [
            'type' => 'input',
            'renderType' => 'inputDateTime',
            'dbType' => 'datetime',
            'eval' => 'datetime,null',
        ],
    ],
],

Steps to reproduce the problem

  • Input the following values in the backend record editor
    • 00:00 01-01-1970
  • Save the form

Actual results

Database:
  • 0000-00-00 00:00:00
    (Default value for datetime)

Expected results:

Database:
  • 1970-01-01 00:00:00

Additional notes

  • There was already some discussion on https://review.typo3.org/c/Packages/TYPO3.CMS/+/66670 , but got outsourced to here
  • Also influences time inputs (e.g. 00:00), however works out in the end
  • Problem location: DataHandler -> checkValueForInput
  • The input gets converted to a tiemstamp for the "sake of checks".
    In this case, the resulting timestamp is 0 and interpreted as false in the following checks (both need to be fixed)
if (isset($tcaFieldConf['dbType']) && isset($res['value']) && !$res['value']) {
    // set the value to null if we have an empty value for a native field
    $res['value'] = null;
}

$res['value'] = $res['value'] ? gmdate($format, $res['value']) : $emptyValue;

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #99847: Null value for time field is ignored in BEResolved2023-02-06

Actions
Actions

Also available in: Atom PDF