8000 [Mime] When serializing File parts convert to string to to allow prop… · jschaedl/symfony@33408bc · GitHub
[go: up one dir, main page]

Skip to content

Commit 33408bc

Browse files
committed
[Mime] When serializing File parts convert to string to to allow proper unserialization. Fixes symfony#47991.
1 parent f3a180b commit 33408bc

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Component/Mime/Part/TextPart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private function chooseEncoding(): string
218218
public function __sleep(): array
219219
{
220220
// convert resources to strings for serialization
221-
if (null !== $this->seekable) {
221+
if (null !== $this->seekable || $this->body instanceof File) {
222222
$this->body = $this->getBody();
223223
$this->seekable = null;
224224
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ public function testSerialize()
483483
$name = __DIR__.'/Fixtures/mimetypes/test';
484484
$file = fopen($name, 'r');
485485
$e->addPart(new DataPart($file, 'test'));
486+
$e->attachFromPath($name, 'same_test');
486487
$expected = clone $e;
487488
$n = unserialize(serialize($e));
488489
$this->assertEquals($expected->getHeaders(), $n->getHeaders());

0 commit comments

Comments
 (0)
0