Skip to content

Commit 02acd86

Browse files
[Mime] Fix serializing uninitialized RawMessage::$message to null
1 parent c2b504e commit 02acd86

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Normalizer/MimeMessageNormalizer.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Mime\Header\UnstructuredHeader;
1818
use Symfony\Component\Mime\Message;
1919
use Symfony\Component\Mime\Part\AbstractPart;
20+
use Symfony\Component\Mime\RawMessage;
2021
use Symfony\Component\Serializer\SerializerAwareInterface;
2122
use Symfony\Component\Serializer\SerializerInterface;
2223

@@ -63,15 +64,18 @@ public function normalize($object, ?string $format = null, array $context = [])
6364
return $ret;
6465
}
6566

67+
$ret = $this->normalizer->normalize($object, $format, $context);
68+
6669
if ($object instanceof AbstractPart) {
67-
$ret = $this->normalizer->normalize($object, $format, $context);
6870
$ret['class'] = \get_class($object);
6971
unset($ret['seekable'], $ret['cid'], $ret['handle']);
72+
}
7073

71-
return $ret;
74+
if ($object instanceof RawMessage && \array_key_exists('message', $ret) && null === $ret['message']) {
75+
unset($ret['message']);
7276
}
7377

74-
return $this->normalizer->normalize($object, $format, $context);
78+
return $ret;
7579
}
7680

7781
/**

0 commit comments

Comments
 (0)