Skip to content

Commit

Permalink
bug #52232 [Messenger] declare constructor argument as optional for b…
Browse files Browse the repository at this point in the history
…ackwards 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 #51468 (comment)
| License       | MIT

Commits
-------

3810053 declare constructor argument as optional for backwards compatibility
  • Loading branch information
nicolas-grekas committed Oct 25, 2023
2 parents c1bf14f + 3810053 commit 3a78c70
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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
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 3a78c70

Please sign in to comment.