#105277Could not convert PHP value 0 to type date. Expected one of the following types: null, string, DateTime
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
\Vendor\Package\Domain\Model\Date\Date
Reviews 3
History 910
-
ondro no-lastname-given commented <span data-processor="relativetime" data-value="2024-10-11T13:06:30+00:00" > 10/11/24, 13:06 </span>
-
Garvin Hicking commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2024-10-11T15:16:58+00:00" > 10/11/24, 15:16 </span>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 -
B. Kausch commented <span data-processor="relativetime" data-value="2025-02-17T17:14:11+00:00" > 02/17/25, 17:14 </span>
Will this be fixed in the near future?
-
Garvin Hicking commented <span data-processor="relativetime" data-value="2025-02-17T18:14:57+00:00" > 02/17/25, 18:14 </span>
No patch has yet been contributed, so my question still applied…
Would you like to contribute the patch to get it “into the system”?
Also probably check if 13.4.5 might have addressed this. Meanwhile a couple DateTime related changes were merged.
-
Benjamin Franzke changed parent task #77562 <span data-processor="relativetime" data-value="2025-03-20T13:09:27+00:00" > 03/20/25, 13:09 </span>
-
Benjamin Franzke commented and changed status
Needs FeedbackAccepted <span data-processor="relativetime" data-value="2025-03-31T08:05:11+00:00" > 03/31/25, 08:05 </span>This has (very likely) been fixed in main (not in v13 and not in v12 :\ ) implicitly by
https://review.typo3.org/c/Packages/TYPO3.CMS/+/85811 and https://review.typo3.org/c/Packages/TYPO3.CMS/+/87380The first patch changed the algorithm to resolve
DateTimeFieldTypebefore relations (but still set relations, therefore probably did not fix the issue yet):
https://github.com/TYPO3/typo3/commit/6c7b876c7a7f20b525768a0346d741aff3dffea4#diff-8d2a830dd11339252fdc315f90b2cf9a9e5c4bc26814401fe6622d71b728b6e4R67-R70
6c7b876c7a7f20b525768a0346d741aff3dffea4
And the second one caused datetime resolution to stop further relation resolutions:
https://github.com/TYPO3/typo3/commit/ad7ec54e54ecb38ca6d53229d5dff6e2745453c1#diff-8d2a830dd11339252fdc315f90b2cf9a9e5c4bc26814401fe6622d71b728b6e4R75We should/could at least add a test for main to verify the fix and ensure it does not break again and maybe even backport parts of it to v13.
CC
obartschlolli -
Benjamin Franzke commented <span data-processor="relativetime" data-value="2025-04-01T04:36:39+00:00" > 04/01/25, 04:36 </span>
I pushed a test that verifies that the issue is resolved in main (fails in v13):
> 88872: [TASK] Add functional test for Extbase mapping to DateTime subclasses | https://review.typo3.org/c/Packages/TYPO3.CMS/+/88872
Still need to sort out some details (there is an existing test that did not fail, probably because it tested too lowlevel).
And we could use that as base for a manual v13 fix. As TYPO3 v12 is in priority bugfix mode, this will rather not be backported to v12. -
Gerrit Code Review pushed patch set 2 for main to change 88872 status
AcceptedUnder Review <span data-processor="relativetime" data-value="2025-05-30T11:55:17+00:00" > 05/30/25, 11:55 </span> -
Benjamin Franzke commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2025-06-02T13:25:09+00:00" > 06/02/25, 13:25 </span>Applied in changeset commit:827201c78508d6928c2371006f68f8cf7805e7cb.
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2025-12-02T14:32:48+00:00" > 12/02/25, 14:32 </span>
Just hotfix: https://github.com/devskio/typo3/commit/69773591a1b62ab93ba5efe28054883f30cb1791