Skip to content

Commit af61482

Browse files
authored
fix(symfony)!: context stamp not serializable because of request object (#6323)
BREAKING CHANGE: unset request object from context array passed to the context stamp
1 parent 61bc8b6 commit af61482

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/Symfony/Messenger/ContextStamp.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ final class ContextStamp implements StampInterface
2727

2828
public function __construct(array $context = [])
2929
{
30-
if (($request = ($context['request'] ?? null)) && $request instanceof Request && $request->hasSession()) {
30+
/* Symfony does not guarantee that the Request object is serializable */
31+
if (($request = ($context['request'] ?? null)) && $request instanceof Request) {
3132
unset($context['request']);
3233
}
3334

tests/Symfony/Messenger/ContextStampTest.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,11 @@ public function testGetContext(): void
3434
$this->assertIsArray($contextStamp->getContext());
3535
}
3636

37-
/**
38-
* @doesNotPerformAssertions
39-
*/
40-
public function testSerializable(): void
37+
public function testRequestIsUnset(): void
4138
{
4239
$request = new Request();
43-
$request->setSessionFactory(function (): void {}); // @phpstan-ignore-line
44-
4540
$stamp = new ContextStamp(['request' => $request]);
46-
serialize($stamp);
41+
42+
self::assertArrayNotHasKey('request', $stamp->getContext());
4743
}
4844
}

0 commit comments

Comments
 (0)