[Live] Fix nullable DateTime hydration with empty value
| Q | A |
|---|---|
| Bug fix? | yes |
| New feature? | no |
| Issues | - |
| License | MIT |
Currently when we send an empty string as value, the new DateTime('') call
creates an object with the current time, which I think is not correct and the
object should be set to null instead.
I'm pretty sure this would have been fixed with the LiveArg implementation we almost sent in 2.18. At least, it was the same root cause: empty string data handle.
But as we realized it has a minor bug, we had to revert it.
So I'd prefer that we find a more generic way to fix these cases... or i fear every specific type issue will need specific patches, with less coherence and a lot of similar code in various places.
Would you like to have a look at it ?
@1ed did you have time to read the other PR i'd be curious to have your opinion...
They may not but they are really due to the same thing (empty data-attribute or input in HTML sending "" and so interpreted as empty strings in PHP)
Maybe you would have a fresh look / opinion on that matter ?
@smnandre instead of reverting #1694 , we could look at implementing this:
Perhaps in the supports method of LiveArgValueResolverTrait we could, after confirming that it's a LiveArg, move the value from _component_action_args to just the attributes but not return any values if the type is expected to be an object. Then the doctrine MapEntity will run, and the value will be where MapEntity expects it to be, and resolves the argument.
We had no choice but to revert it, sadly, as it created bugs in rare occasion.
iām 100% open to any solution :)
We had no choice but to revert it, sadly, as it created bugs in rare occasion.
are the bugs documented somewhere or could we add tests that cover current behaviour (other than the ones we already had)? I could take out the bugs but Iād have to be aware of the current situation š
@jannes-io No, still this problem with Doctrine / other valueresolvers, but this was enough to not release it like that š