ux icon indicating copy to clipboard operation
ux copied to clipboard

[Live] Fix nullable DateTime hydration with empty value

Open 1ed opened this issue 1 year ago • 6 comments

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.

1ed avatar Jun 09 '24 22:06 1ed

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 ?

smnandre avatar Jun 10 '24 21:06 smnandre

@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 avatar Jun 14 '24 19:06 smnandre

@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.

jannes-io avatar Jun 19 '24 17:06 jannes-io

We had no choice but to revert it, sadly, as it created bugs in rare occasion.

i’m 100% open to any solution :)

smnandre avatar Jun 19 '24 17:06 smnandre

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 avatar Jun 19 '24 17:06 jannes-io

@jannes-io No, still this problem with Doctrine / other valueresolvers, but this was enough to not release it like that šŸ˜…

smnandre avatar Jun 20 '24 03:06 smnandre