8000 bug #53678 [Mime] Fix serializing uninitialized `RawMessage::$message… · symfony/symfony@a63f545 · GitHub
[go: up one dir, main page]

Skip to content

Commit a63f545

Browse files
bug #53678 [Mime] Fix serializing uninitialized RawMessage::$message to null (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- [Mime] Fix serializing uninitialized `RawMessage::$message` to null | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #53664 | License | MIT Commits ------- 122f58c [Mime] Fix serializing uninitialized RawMessage::$message to null
2 parents a67e8bd + 122f58c commit a63f545

File tree

7 files changed

+16
-12
lines changed

7 files changed

+16
-12
lines changed

src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ public function testSymfonySerialize()
9494
}
9595
]
9696
},
97-
"body": null,
98-
"message": null
97+
"body": null
9998
}
10099
EOF;
101100

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"symfony/security-core": "^4.4|^5.0|^6.0",
4343
"symfony/security-csrf": "^4.4|^5.0|^6.0",
4444
"symfony/security-http": "^4.4|^5.0|^6.0",
45-
"symfony/serializer": "^5.2|^6.0",
45+
"symfony/serializer": "^5.4.35|~6.3.12|^6.4.3",
4646
"symfony/stopwatch": "^4.4|^5.0|^6.0",
4747
"symfony/console": "^5.3|^6.0",
4848
"symfony/expression-language": "^4.4|^5.0|^6.0",

src/Symfony/Component/Mime/RawMessage.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
*/
1919
class RawMessage implements \Serializable
2020
{
21+
/**
22+
* @var iterable|string
23+
*/
2124
private $message;
2225

2326
/**

src/Symfony/Component/Mime/Tests/EmailTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,7 @@ public function testSymfonySerialize()
547547
}
548548
]
549549
},
550-
"body": null,
551-
"message": null
550+
"body": null
552551
}
553552
EOF;
554553

src/Symfony/Component/Mime/Tests/MessageTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,7 @@ public function testSymfonySerialize()
254254
]
255255
},
256256
"class": "Symfony\\\\Component\\\\Mime\\\\Part\\\\Multipart\\\\MixedPart"
257-
},
258-
"message": null
257+
}
259258
}
260259
EOF;
261260

src/Symfony/Component/Mime/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
2929
"symfony/property-access": "^4.4|^5.1|^6.0",
3030
"symfony/property-info": "^4.4|^5.1|^6.0",
31-
"symfony/serializer": "^5.4.26|~6.2.13|^6.3.2"
31+
"symfony/serializer": "^5.4.35|~6.3.12|^6.4.3"
3232
},
3333
"conflict": {
3434
"egulias/email-validator": "~3.0.0",
3535
"phpdocumentor/reflection-docblock": "<3.2.2",
3636
"phpdocumentor/type-resolver": "<1.4.0",
3737
"symfony/mailer": "<4.4",
38-
"symfony/serializer": "<5.4.26|>=6,<6.2.13|>=6.3,<6.3.2"
38+
"symfony/serializer": "<5.4.35|>=6,<6.3.12|>=6.4,<6.4.3"
3939
},
4040
"autoload": {
4141
"psr-4": { "Symfony\\Component\\Mime\\": "" },

src/Symfony/Component/Serializer/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)
0