Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Serializer] Xml encoder throws exception for valid data #21617

Copy link
Copy link
Closed
@gr1ev0us

Description

@gr1ev0us
Issue body actions
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 2.7.x

The problem is in a xml serialization array/object contained DateTime object. To normalize this i am using DateTimeNormalizer (it appeared in sf 3.2, but in my project I use my custom implementation). As a result I get an UnexpectedValueException.

How to reproduce a bug:

use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Encoder\XmlEncoder;

$serializer = (new Serializer([new DateTimeNormalizer, new XmlEncoder]));

$result = $serializer->serialize(['node'=> new DateTime('2017-02-13T17:54:23+0300')]);

expects:

<response><node>2017-02-13T17:54:23+0300</node></response>

actual: An unexpected value could not be serialized: '2017-02-13T17:54:23+0300'

I suppose, there is no need to normalize value before buildXml invocation:
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php#L480

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.