Skip to content

[Messenger] remove legacy code paths #41421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions src/Symfony/Component/Messenger/Envelope.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function withoutAll(string $stampFqcn): self
{
$cloned = clone $this;

unset($cloned->stamps[$this->resolveAlias($stampFqcn)]);
unset($cloned->stamps[$stampFqcn]);

return $cloned;
}
Expand All @@ -84,7 +84,6 @@ public function withoutAll(string $stampFqcn): self
public function withoutStampsOfType(string $type): self
{
$cloned = clone $this;
$type = $this->resolveAlias($type);

foreach ($cloned->stamps as $class => $stamps) {
if ($class === $type || is_subclass_of($class, $type)) {
Expand All @@ -97,7 +96,7 @@ public function withoutStampsOfType(string $type): self

public function last(string $stampFqcn): ?StampInterface
{
return isset($this->stamps[$stampFqcn = $this->resolveAlias($stampFqcn)]) ? end($this->stamps[$stampFqcn]) : null;
return isset($this->stamps[$stampFqcn = $stampFqcn]) ? end($this->stamps[$stampFqcn]) : null;
}

/**
Expand All @@ -106,7 +105,7 @@ public function last(string $stampFqcn): ?StampInterface
public function all(string $stampFqcn = null): array
{
if (null !== $stampFqcn) {
return $this->stamps[$this->resolveAlias($stampFqcn)] ?? [];
return $this->stamps[$stampFqcn] ?? [];
}

return $this->stamps;
Expand All @@ -119,14 +118,4 @@ public function getMessage(): object
{
return $this->message;
}

/**
* BC to be removed in 6.0.
*/
private function resolveAlias(string $fqcn): string
{
static $resolved;

return $resolved[$fqcn] ?? ($resolved[$fqcn] = (new \ReflectionClass($fqcn))->getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpReceivedStamp;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\RejectRedeliveredMessageException;
use Symfony\Component\Messenger\Transport\AmqpExt\AmqpReceivedStamp as LegacyAmqpReceivedStamp;

/**
* Middleware that throws a RejectRedeliveredMessageException when a message is detected that has been redelivered by AMQP.
Expand All @@ -39,12 +38,6 @@ public function handle(Envelope $envelope, StackInterface $stack): Envelope
throw new RejectRedeliveredMessageException('Redelivered message from AMQP detected that will be rejected and trigger the retry logic.');
}

// Legacy code to support symfony/messenger < 5.1
$amqpReceivedStamp = $envelope->last(LegacyAmqpReceivedStamp::class);
if ($amqpReceivedStamp instanceof LegacyAmqpReceivedStamp && $amqpReceivedStamp->getAmqpEnvelope()->isRedelivery()) {
throw new RejectRedeliveredMessageException('Redelivered message from AMQP detected that will be rejected and trigger the retry logic.');
}

return $stack->next()->handle($envelope, $stack);
}
}