Skip to content

Commit b33313d

Browse files
Merge branch '6.4' into 7.0
* 6.4: [AssetMapper] Allow simple, relative paths in importmap.php [PropertyInfo] Make isWriteable() more consistent with isReadable() when checking snake_case properties [AssetMapper] Add support for CSS files in the importmap [Messenger] Add `--all` option to the `messenger:failed:remove` command Fix merge fix #51235 - fix the order of merging of serializationContext and self::CONTEXT_DENORMALIZE [HttpClient] Fix Static Code Analyzer issue with JsonMockResponse [Messenger] Fix exiting `FailedMessagesRetryCommand` [Serializer] Fix reindex normalizedData array in AbstractObjectNormalizer::denormalize() remove an unreachable code branch [Validator] Fix `File::$extensions`’ PHPDoc [Mime] Fix email (de)serialization issues [FrameworkBundle][WebProfilerBundle][Console][Form][HttpKernel][PropertyInfo][Validator] Remove optional before required param Replace usages of SkippedTestSuiteError with markTestSkipped() call Update InteractiveAuthenticatorInterface description wording to match documentation [Serializer] Fix parsing XML root node attributes fix parsing of payload timestamp to DateTimeImmutable Fix routing to multiple fallback transports Fix missing stamps in delayed message handling [DoctrineBridge] Ignore invalid stores in `LockStoreSchemaListener` raised by `StoreFactory`
2 parents ae1be23 + fae6d88 commit b33313d

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

Part/DataPart.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function __wakeup(): void
154154
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
155155
}
156156
foreach (['body', 'charset', 'subtype', 'disposition', 'name', 'encoding'] as $name) {
157-
if (null !== $this->_parent[$name] && !\is_string($this->_parent[$name])) {
157+
if (null !== $this->_parent[$name] && !\is_string($this->_parent[$name]) && !$this->_parent[$name] instanceof File) {
158158
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
159159
}
160160
$r = new \ReflectionProperty(TextPart::class, $name);

Part/TextPart.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private function chooseEncoding(): string
222222
public function __sleep(): array
223223
{
224224
// convert resources to strings for serialization
225-
if (null !== $this->seekable || $this->body instanceof File) {
225+
if (null !== $this->seekable) {
226226
$this->body = $this->getBody();
227227
$this->seekable = null;
228228
}

Tests/EmailTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -658,4 +658,34 @@ public function testBodyCache()
658658
$body2 = $email->getBody();
659659
$this->assertNotSame($body1, $body2, 'The two bodies must not reference the same object, so the body cache does not ensure that the hash for the DKIM signature is unique.');
660660
}
661+
662+
public function testAttachmentBodyIsPartOfTheSerializationEmailPayloadWhenUsingAttachMethod()
663+
{
664+
$email = new Email();
665+
$email->attach(file_get_contents(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'foo_attachment.txt') ?: '');
666+
667+
$this->assertTrue(str_contains(serialize($email), 'foo_bar_xyz_123'));
668+
}
669+
670+
public function testAttachmentBodyIsNotPartOfTheSerializationEmailPayloadWhenUsingAttachFromPathMethod()
671+
{
672+
$email = new Email();
673+
$email->attachFromPath(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'foo_attachment.txt');
674+
675+
$this->assertFalse(str_contains(serialize($email), 'foo_bar_xyz_123'));
676+
}
677+
678+
public function testEmailsWithAttachmentsWhichAreAFileInstanceCanBeUnserialized()
679+
{
680+
$email = new Email();
681+
$email->attachFromPath(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'foo_attachment.txt');
682+
683+
$email = unserialize(serialize($email));
684+
$this->assertInstanceOf(Email::class, $email);
685+
686+
$attachments = $email->getAttachments();
687+
688+
$this->assertCount(1, $attachments);
689+
$this->assertStringContainsString('foo_bar_xyz_123', $attachments[0]->getBody());
690+
}
661691
}

Tests/Fixtures/foo_attachment.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo_bar_xyz_123

0 commit comments

Comments
 (0)