Skip to content

Commit

Permalink
declare constructor argument as optional for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Oct 22, 2023
1 parent 6637b78 commit 3810053
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
class DelayedMessageHandlingException extends RuntimeException
{
private array $exceptions;
private Envelope $envelope;
private ?Envelope $envelope;

public function __construct(array $exceptions, Envelope $envelope)
public function __construct(array $exceptions, Envelope $envelope = null)
{
$this->envelope = $envelope;

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

public function getEnvelope(): Envelope
public function getEnvelope(): ?Envelope
{
return $this->envelope;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Messenger/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private function ack(): bool
$receiver->reject($envelope);
}

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

Expand Down

0 comments on commit 3810053

Please sign in to comment.