Skip to content

Commit 3a78c70

Browse files
bug symfony#52232 [Messenger] declare constructor argument as optional for backwards compatibility (xabbuh)
This PR was merged into the 6.3 branch. Discussion ---------- [Messenger] declare constructor argument as optional for backwards compatibility | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix symfony#51468 (comment) | License | MIT Commits ------- 3810053 declare constructor argument as optional for backwards compatibility
2 parents c1bf14f + 3810053 commit 3a78c70

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Symfony/Component/Messenger/Exception/DelayedMessageHandlingException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
class DelayedMessageHandlingException extends RuntimeException
2323
{
2424
private array $exceptions;
25-
private Envelope $envelope;
25+
private ?Envelope $envelope;
2626

27-
public function __construct(array $exceptions, Envelope $envelope)
27+
public function __construct(array $exceptions, Envelope $envelope = null)
2828
{
2929
$this->envelope = $envelope;
3030

@@ -49,7 +49,7 @@ public function getExceptions(): array
4949
return $this->exceptions;
5050
}
5151

52-
public function getEnvelope(): Envelope
52+
public function getEnvelope(): ?Envelope
5353
{
5454
return $this->envelope;
5555
}

src/Symfony/Component/Messenger/Worker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private function ack(): bool
187187
$receiver->reject($envelope);
188188
}
189189

190-
if ($e instanceof HandlerFailedException || $e instanceof DelayedMessageHandlingException) {
190+
if ($e instanceof HandlerFailedException || ($e instanceof DelayedMessageHandlingException && null !== $e->getEnvelope())) {
191191
$envelope = $e->getEnvelope();
192192
}
193193

0 commit comments

Comments
 (0)