-
-
Notifications
You must be signed in to change notification settings - Fork 585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix xml deserialization when xsi:nil="true" is set #771
Fix xml deserialization when xsi:nil="true" is set #771
Conversation
@schmittjoh This lib rocks and serialization to xml works like a charm with xsi:nil included! The deserialization did nothing with it however, hence the fix! 👍 |
Hi @Bouwdie, thanks for your PR. Your PR is not backward compatible (it adds a public method on an interface), and in the current roadmap of the serializer, can not be accepted. The 2.0 release date is not yet defined. I see a value in your work and I'm interested in supporting this use case (also for the json usecase if not already implemented)... Can this be implemented keeping backward compatibility? |
Hi @goetas Thanks for your super quick reply! I fully agree that this change is a BC change. The reason it is in the interface is that it is not necessarily xml specific. I am doubting between two approaches here; moving it directly into the XmlDeserializer (which i don't like) or introduce a new interface. A new interface would be nice anyway since the method is not necessarily visitor specific. BTW - The json use-case works outside the box since there is no additional layer like simplexml (null = null). |
I like the interface approach, but consider that you will introduce probably a BC break anyway.... Consider this class class Foo
{
/** @Type("int") **/
public $id;
} and this json (valid for xml too...) {
"id":null
} $foo = $serializer->deserialize($json, Foo:class, 'json');
var_dump($foo->id) The result will be: Current code (v1.7.1): With your code: |
Indeed this would we a change of the current behaviour. It however would solely be a change in behaviour for the XML de-serialization. The fact that the |
false, because of the changes on the abstractvisitor and graph navigator... you can add a custom xml deserializer to handle xsd:nil... and forward everything else to the xml serializer... |
All of the changes are so that old functionality stays the same (that's the thought), except for the xml-deserializer. I could move this into a custom de-serializer downstream, and this nice lib would stay with this inconsistency. Or would you consider a custom xml-deserializer + docs into the 1.7 branch for now with a permanent fix in 2? |
So the (XML) deserialization behavior will stay incorrect because of the BC break? |
Add xml deserialization null check based on xsi:nil Expand visitor interface with a null data detect function Add default implementation for null detection in abstract visitor Add round-trip test for serializing ad de-serializing null object
Only the XMLDeserializationVisitor implements the `NullEvaluatorInterface` Restored behaviour in the GraphNavigator for the SerializationContext (elseif branch) Removed now obsolete tests from the BaseSerializationTest
f888b6e
to
1f9021e
Compare
Last thoughts:
If you have any other suggestions please let me know 🍔 + thanks again for taking the time to maintain this library; it is highly appreciated! 👍 |
Hi, thanks for doing the changes to your PR, now looks definitively more clean. Please allow me some time to test and think about this PR since it introduces a couple of important changes. |
@goetas Any thoughts regarding the PR already? 😺 |
Add xml deserialization null check based on xsi:nil
Expand visitor interface with a null data detect function
Add default implementation for null detection in abstract visitor
Add round-trip test for serializing ad de-serializing null object
(Silence operator had to be used - even a count() on the attributes resulted in this error)