Skip to content
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

Deserializing XMLList with Namespaces not (always) working as intended #695

Closed
fivetide opened this issue Jan 9, 2017 · 3 comments
Closed
Assignees

Comments

@fivetide
Copy link

fivetide commented Jan 9, 2017

Deserializing XML with only namespaced child-nodes does not work as intended (in #675).

My testcase, derived from testObjectWithNamespacesAndList():

public function testObjectWithOnlyNamespacesAndList()
    {
        $object = new ObjectWithNamespacesAndList();

        $object->phones = array();
        $object->addresses = array();

        $object->phonesAlternativeB = array();
        $object->addressesAlternativeB = array();

        $object->phonesAlternativeC = array('777', '888');
        $object->addressesAlternativeC = array('A'=>'Street 7', 'B'=>'Street 8');

        $object->phonesAlternativeD = array();
        $object->addressesAlternativeD = array();

        $this->assertEquals(
            $this->getContent('object_with_only_namespaces_and_list'),
            $this->serialize($object, SerializationContext::create())
        );
        $this->assertEquals(
            $object,
            $this->deserialize($this->getContent('object_with_only_namespaces_and_list'), get_class($object))
        );
    }

with this xml:

<?xml version="1.0" encoding="UTF-8"?>
<ObjectWithNamespacesAndList xmlns="http://example.com/namespace" xmlns:x="http://example.com/namespace2">
  <x:phone><![CDATA[777]]></x:phone>
  <x:phone><![CDATA[888]]></x:phone>
  <x:address id="A"><![CDATA[Street 7]]></x:address>
  <x:address id="B"><![CDATA[Street 8]]></x:address>
</ObjectWithNamespacesAndList>

currently fails because of src/JMS/Serializer/XmlDeserializationVisitor.php:153

0 === $data->count()

(see https://3v4l.org/n7o8I).

I would like to provide a PR to solve this, but my current approaches both seem subobtimal, either just silencing the warning from #674, or using a temporary error-handler every time $hasNode is determined...
What do you think?

twtgrowth pushed a commit to twtgrowth/serializer that referenced this issue Jan 9, 2017
…ent.

fixes Deserializing XMLList with Namespaces not (always) working as intended schmittjoh#695
@goetas goetas self-assigned this Jan 9, 2017
@goetas
Copy link
Collaborator

goetas commented Jan 9, 2017

What about https://3v4l.org/EatEF ?

@goetas
Copy link
Collaborator

goetas commented Jan 9, 2017

see #697 as alternative

@goetas
Copy link
Collaborator

goetas commented Jan 19, 2017

solved in #697

@goetas goetas closed this as completed Jan 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants