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

Commit 300408c

Browse filesBrowse files
committed
bug #47702 [Messenger] Fix default serializer not handling DateTime objects properly (barton-webwings)
This PR was merged into the 4.4 branch. Discussion ---------- [Messenger] Fix default serializer not handling DateTime objects properly | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | -- | License | MIT | Doc PR | -- I was using messenger standalone and needed to send messages in JSON format. While trying to do so using the Serializer class, I noticed that DateTime objects (present for example in RedeliveryStamp) are not serialized properly. I fixed it by adding the proper normalizer. I encountered it in version 5.2, but it should be applicable from version 4.4. Before: ![before](https://user-images.githubusercontent.com/109534378/192502327-22973a95-d26c-4aa7-9a12-089109fc4185.png) After: ![after](https://user-images.githubusercontent.com/109534378/192502452-75f36ecc-a2fe-41b7-96dc-b54b0b602206.png) Commits ------- 85c459c [Messenger] Fix default serializer not handling DateTime objects properly
2 parents 216b339 + 85c459c commit 300408c
Copy full SHA for 300408c

File tree

Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed

‎src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Transport/Serialization/Serializer.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Serializer\Encoder\XmlEncoder;
2222
use Symfony\Component\Serializer\Exception\ExceptionInterface;
2323
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
24+
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
2425
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
2526
use Symfony\Component\Serializer\Serializer as SymfonySerializer;
2627
use Symfony\Component\Serializer\SerializerInterface as SymfonySerializerInterface;
@@ -50,7 +51,7 @@ public static function create(): self
5051
}
5152

5253
$encoders = [new XmlEncoder(), new JsonEncoder()];
53-
$normalizers = [new ArrayDenormalizer(), new ObjectNormalizer()];
54+
$normalizers = [new DateTimeNormalizer(), new ArrayDenormalizer(), new ObjectNormalizer()];
5455
$serializer = new SymfonySerializer($normalizers, $encoders);
5556

5657
return new self($serializer);

0 commit comments

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