#111623Map request arguments to DateTimeImmutable properties
Description
Extbase persists and reconstitutes \DateTimeImmutable properties of domain models, and the DateTimeValidator accepts them. The property mapper does not: the DateTimeConverter is registered for the target type DateTime only and returns a \DateTime. A \DateTimeImmutable action argument or a \DateTimeImmutable property of a submitted object or a demand passed in a link cannot be mapped from the request.
The property mapper should convert the same sources (string, integer, array with date, dateFormat, hour, minute, second and timezone) into \DateTimeImmutable as well, with the same configuration options (CONFIGURATION_DATE_FORMAT) and the same errors as for \DateTime. Ideally \DateTimeInterface as target type maps too.
Background: models should prefer immutable dates. Extbase detects a \DateTime that is modified in place because the clean state tracker compares a clone of the original with ==. An ORM that compares by identity, like doctrine/orm, does not see such a change. With \DateTimeImmutable the value has to be replaced, which every comparison detects. Recommending immutable dates needs the property mapper to support them.
Found with the round trip tests for #111621, where a \DateTimeImmutable property of a link argument cannot be mapped back.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch
- Commit message
-
[FEATURE] Map request arguments to DateTimeImmutable properties Resolves: #111623 Releases: main