Project

General

Profile

Actions

Bug #105277

open

Could not convert PHP value 0 to type date. Expected one of the following types: null, string, DateTime

Added by ondro no-lastname-given about 1 month ago. Updated about 1 month ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2024-10-11
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.3
Tags:
extbase, columnMap
Complexity:
medium
Is Regression:
Sprint Focus:

Description

I have have extbase model with following property:

    /**
     * @var \Vendor\Package\Domain\Model\Date\Date
     */
    protected $phase = null;
\Vendor\Package\Domain\Model\Date\Date extends \DateTime

Phase TCA config looks as follow:

         'phase' => [
            'label' => 'Phase',
            'config' => [
                'type' => 'datetime',
                'dbType' => 'date',
                'format' => 'date',
            ],
        ],

MySQL:

phase1_start date DEFAULT NULL,

On the first model save and DB insert following error occurs:

Causes error: Could not convert PHP value 0 to type date. Expected one of the following types: null, string, DateTime

I found out problem lays here: https://github.com/TYPO3/typo3/blob/v12.4.21/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/ColumnMapFactory.php#L101

\DateTime
typeOfRelation is NONE
\Vendor\Package\Domain\Model\Date\Date
typeOfRelation is HAS_ONE
Actions #2

Updated by Garvin Hicking about 1 month ago

  • Status changed from New to Needs Feedback

Hey,

thank your for sharing the report and a possible fix. Definitely Extbase and some other areas in TYPO3 still have possible issues with "real" date SQL fields (most functionality was aimed at timestamps). So your effort is very welcome in improving this!

Would you be interested to share your patch for TYPO3 along usual contribution guidelines? Then your patch could also be verified with our CI testing setup. (I could do that for you, but if you're interested, that would help us get this better off the ground and see if you may find follow up issues). If so, please check out https://docs.typo3.org/m/typo3/guide-contributionworkflow/main/en-us/Quickstart/Index.html#quickstart

Thanks,
Garvin

Actions

Also available in: Atom PDF