Update src/Guzzle/Service/Command/LocationVisitor/Request/XmlVisitor.php #182

Closed
wants to merge 1 commit into
from

2 participants

@rh389

$property may have been configured with filters.

When $property is an object or array these filters are applied by addXML, but other types are added directly to the SimpleXMLElement so that filters are never applied.

Modified to use addXml recursively instead of directly adding children/attributes to the simpleXMLElement, this accounts for filtering (and also removes the duplication relating to xmlAttribute)

@rh389 rh389 Update src/Guzzle/Service/Command/LocationVisitor/Request/XmlVisitor.php
$property may have been configured with filters. 

When $property is an object or array these filters are applied by addXML, but other types are added directly to the SimpleXMLElement so that filters are never applied.

Modified to use addXml recursively instead of directly adding children/attributes to the simpleXMLElement, this accounts for filtering.
b3ae632
@mtdowling
Guzzle member

This looks good, but unfortunately, it causes commands like this to fail. Instead of the XML being sent as:

<?xml version="1.0"?>
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <Owner>
        <ID>foo</ID>
        <DisplayName>baz</DisplayName>
    </Owner>
    <AccessControlList>
        <Grant>
            <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
                <URI>http://acs.amazonaws.com/groups/global/AuthenticatedUsers</URI>
            </Grantee>
            <Permission>READ</Permission>
        </Grant>
        <Grant>
            <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
                <URI>http://acs.amazonaws.com/groups/global/AllUsers</URI>
            </Grantee>
            <Permission>READ_ACP</Permission>
        </Grant>
    </AccessControlList>
</AccessControlPolicy>

It gets sent as:

<?xml version="1.0"?>
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <Owner>
        <ID>foo</ID>
        <DisplayName>baz</DisplayName>
    </Owner>
    <AccessControlList>
        <Grant>
            <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
                <URI>http://acs.amazonaws.com/groups/global/AuthenticatedUsers</URI>
                <Permission>READ</Permission>
            </Grantee>
        </Grant>
        <Grant>
            <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
                <URI>http://acs.amazonaws.com/groups/global/AllUsers</URI>
                <Permission>READ_ACP</Permission>
            </Grantee>
        </Grant>
    </AccessControlList>
</AccessControlPolicy>

I should add a test around this, but we don't have a test currently.

@mtdowling mtdowling added a commit that closed this pull request Jan 10, 2013
@mtdowling mtdowling Cleaning up the XML serializer
Closes #182
625cc42
@mtdowling mtdowling closed this in 625cc42 Jan 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment