8000 [Messenger] Removed deprecated code · symfony/symfony@d328c1f · GitHub
[go: up one dir, main page]

Skip to content

Commit d328c1f

Browse files
committed
[Messenger] Removed deprecated code
1 parent 0eb382a commit d328c1f

File tree

8 files changed

+23
-72
lines changed

8 files changed

+23
-72
lines changed

src/Symfony/Component/Messenger/Bridge/Amqp/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
6.0
5+
---
6+
7+
* Remove option `prefetch_count`
8+
* Using invalid options will throw a `LogicException`
9+
410
5.3
511
---
612

src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class Connection
4343
'exchange',
4444
'delay',
4545
'auto_setup',
46-
'prefetch_count',
4746
'retry',
4847
'persistent',
4948
'frame_max',
@@ -238,11 +237,7 @@ public static function fromDsn(string $dsn, array $options = [], AmqpFactory $am
238237
private static function validateOptions(array $options): void
239238
{
240239
if (0 < \count($invalidOptions = array_diff(array_keys($options), self::AVAILABLE_OPTIONS))) {
241-
trigger_deprecation('symfony/messenger', '5.1', 'Invalid option(s) "%s" passed to the AMQP Messenger transport. Passing invalid options is deprecated.', implode('", "', $invalidOptions));
242-
}
243-
244-
if (isset($options['prefetch_count'])) {
245-
trigger_deprecation('symfony/messenger', '5.3', 'The "prefetch_count" option passed to the AMQP Messenger transport has no effect and should not be used.');
240+
throw new LogicException(sprintf('Invalid option(s) "%s" passed to the AMQP Messenger transport.', implode('", "', $invalidOptions)));
246241
}
247242

248243
if (\is_array($options['queues'] ?? false)) {
@@ -252,14 +247,14 @@ private static function validateOptions(array $options): void
252247
}
253248

254249
if (0 < \count($invalidQueueOptions = array_diff(array_keys($queue), self::AVAILABLE_QUEUE_OPTIONS))) {
255-
trigger_deprecation('symfony/messenger', '5.1', 'Invalid queue option(s) "%s" passed to the AMQP Messenger transport. Passing invalid queue options is deprecated.', implode('", "', $invalidQueueOptions));
250+
throw new LogicException(sprintf('Invalid queue option(s) "%s" passed to the AMQP Messenger transport.', implode('", "', $invalidQueueOptions)));
256251
}
257252
}
258253
}
259254

260255
if (\is_array($options['exchange'] ?? false)
261256
&& 0 < \count($invalidExchangeOptions = array_diff(array_keys($options['exchange']), self::AVAILABLE_EXCHANGE_OPTIONS))) {
262-
trigger_deprecation('symfony/messenger', '5.1', 'Invalid exchange option(s) "%s" passed to the AMQP Messenger transport. Passing invalid exchange options is deprecated.', implode('", "', $invalidExchangeOptions));
257+
throw new LogicException(sprintf('Invalid exchange option(s) "%s" passed to the AMQP Messenger transport.', implode('", "', $invalidExchangeOptions)));
263258
}
264259
}
265260

src/Symfony/Component/Messenger/Bridge/Redis/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
6.0
5+
---
6+
7+
* Remove option `tls`
8+
* Using invalid options will throw a `LogicException`
9+
410
5.3
511
---
612

src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class Connection
3636
'delete_after_reject' => true,
3737
'stream_max_entries' => 0, // any value higher than 0 defines an approximate maximum number of stream entries
3838
'dbindex' => 0,
39-
'tls' => false,
4039
'redeliver_timeout' => 3600, // Timeout before redeliver messages still in pending state (seconds)
4140
'claim_interval' => 60000, // Interval by which pending/abandoned messages should be checked
4241
'lazy' => false,
@@ -189,11 +188,6 @@ public static function fromDsn(string $dsn, array $redisOptions = [], \Redis|\Re
189188
}
190189

191190
$tls = 'rediss' === $parsedUrl['scheme'];
192-
if (\array_key_exists('tls', $redisOptions)) {
193-
trigger_deprecation('symfony/redis-messenger', '5.3', 'Providing "tls" parameter is deprecated, use "rediss://" DSN scheme instead');
194-
$tls = filter_var($redisOptions['tls'], \FILTER_VALIDATE_BOOLEAN);
195-
unset($redisOptions['tls']);
196-
}
197191

198192
$redeliverTimeout = null;
199193
if (\array_key_exists('redeliver_timeout', $redisOptions)) {
@@ -272,7 +266,7 @@ private static function validateOptions(array $options): void
272266
$availableOptions[] = 'serializer';
273267

274268
if (0 < \count($invalidOptions = array_diff(array_keys($options), $availableOptions))) {
275-
trigger_deprecation('symfony/messenger', '5.1', 'Invalid option(s) "%s" passed to the Redis Messenger transport. Passing invalid options is deprecated.', implode('", "', $invalidOptions));
269+
throw new LogicException(sprintf('Invalid option(s) "%s" passed to the Redis Messenger transport.', implode('", "', $invalidOptions)));
276270
}
277271
}
278272

src/Symfony/Component/Messenger/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ CHANGELOG
55
---
66

77
* Remove deprecated classes `Symfony/Component/Messenger/Transport/AmqpExt`, `Symfony/Component/Messenger/Transport/Doctrine` and `Symfony/Component/Messenger/Transport/Redis`.
8+
* Class `MessengerPass` cannot be configured with constructor arguments
9+
* Remove constructor arguments and getters for `RedeliveryStamp`'s properties `exceptionMessage` and `flattenException`
810

911
5.4
1012
---

src/Symfony/Component/Messenger/Command/FailedMessagesShowCommand.php

-4
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,10 @@ private function listMessages(?string $failedTransportName, SymfonyStyle $io, in
102102
$lastRedeliveryStamp = $envelope->last(RedeliveryStamp::class);
103103
/** @var ErrorDetailsStamp|null $lastErrorDetailsStamp */
104104
$lastErrorDetailsStamp = $envelope->last(ErrorDetailsStamp::class);
105-
$lastRedeliveryStampWithException = $this->getLastRedeliveryStampWithException($envelope, true);
106105

107106
$errorMessage = '';
108107
if (null !== $lastErrorDetailsStamp) {
109108
$errorMessage = $lastErrorDetailsStamp->getExceptionMessage();
110-
} elseif (null !== $lastRedeliveryStampWithException) {
111-
// Try reading the errorMessage for messages that are still in the queue without the new ErrorDetailStamps.
112-
$errorMessage = $lastRedeliveryStampWithException->getExceptionMessage();
113109
}
114110

115111
$rows[] = [

src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php

+4-19
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,13 @@
3030
*/
3131
class MessengerPass implements CompilerPassInterface
3232
{
33-
private $handlerTag;
34-
private $busTag;
35-
private $receiverTag;
36-
37-
public function __construct(string $handlerTag = 'messenger.message_handler', string $busTag = 'messenger.bus', string $receiverTag = 'messenger.receiver')
38-
{
39-
if (0 < \func_num_args()) {
40-
trigger_deprecation('symfony/messenger', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
41-
}
42-
43-
$this->handlerTag = $handlerTag;
44-
$this->busTag = $busTag;
45-
$this->receiverTag = $receiverTag;
46-
}
47-
4833
/**
4934
* {@inheritdoc}
5035
*/
5136
public function process(ContainerBuilder $container)
5237
{
5338
$busIds = [];
54-
foreach ($container->findTaggedServiceIds($this->busTag) as $busId => $tags) {
39+
foreach ($container->findTaggedServiceIds('messenger.bus') as $busId => $tags) {
5540
$busIds[] = $busId;
5641
if ($container->hasParameter($busMiddlewareParameter = $busId.'.middleware')) {
5742
$this->registerBusMiddleware($container, $busId, $container->getParameter($busMiddlewareParameter));
@@ -76,10 +61,10 @@ private function registerHandlers(ContainerBuilder $container, array $busIds)
7661
$handlersByBusAndMessage = [];
7762
$handlerToOriginalServiceIdMapping = [];
7863

79-
foreach ($container->findTaggedServiceIds($this->handlerTag, true) as $serviceId => $tags) {
64+
foreach ($container->findTaggedServiceIds('messenger.message_handler', true) as $serviceId => $tags) {
8065
foreach ($tags as $tag) {
8166
if (isset($tag['bus']) && !\in_array($tag['bus'], $busIds, true)) {
82-
throw new RuntimeException(sprintf('Invalid handler service "%s": bus "%s" specified on the tag "%s" does not exist (known ones are: "%s").', $serviceId, $tag['bus'], $this->handlerTag, implode('", "', $busIds)));
67+
throw new RuntimeException(sprintf('Invalid handler service "%s": bus "%s" specified on the tag "messenger.message_handler" does not exist (known ones are: "%s").', $serviceId, $tag['bus'], implode('", "', $busIds)));
8368
}
8469

8570
$className = $this->getServiceClass($container, $serviceId);
@@ -268,7 +253,7 @@ private function registerReceivers(ContainerBuilder $container, array $busIds)
268253
}
269254
}
270255

271-
foreach ($container->findTaggedServiceIds($this->receiverTag) as $id => $tags) {
256+
foreach ($container->findTaggedServiceIds('messenger.receiver') as $id => $tags) {
272257
$receiverClass = $this->getServiceClass($container, $id);
273258
if (!is_subclass_of($receiverClass, ReceiverInterface::class)) {
274259
throw new RuntimeException(sprintf('Invalid receiver "%s": class "%s" must implement interface "%s".', $id, $receiverClass, ReceiverInterface::class));

src/Symfony/Component/Messenger/Stamp/RedeliveryStamp.php

+1-34
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Messenger\Stamp;
1313

14-
use Symfony\Component\ErrorHandler\Exception\FlattenException;
1514
use Symfony\Component\Messenger\Envelope;
1615

1716
/**
@@ -21,23 +20,11 @@ final class RedeliveryStamp implements StampInterface
2120
{
2221
private $retryCount;
2322
private $redeliveredAt;
24-
private $exceptionMessage;
25-
private $flattenException;
2623

27-
public function __construct(int $retryCount, string $exceptionMessage = null, FlattenException $flattenException = null, \DateTimeInterface $redeliveredAt = null)
24+
public function __construct(int $retryCount, \DateTimeInterface $redeliveredAt = null)
2825
{
2926
$this->retryCount = $retryCount;
3027
$this->redeliveredAt = $redeliveredAt ?? new \DateTimeImmutable();
31-
32-
if (null !== $exceptionMessage) {
33-
trigger_deprecation('symfony/messenger', '5.2', sprintf('Using the "$exceptionMessage" parameter in the "%s" class is deprecated, use the "%s" class instead.', self::class, ErrorDetailsStamp::class));
34-
}
35-
$this->exceptionMessage = $exceptionMessage;
36-
37-
if (null !== $flattenException) {
38-
trigger_deprecation('symfony/messenger', '5.2', sprintf('Using the "$flattenException" parameter in the "%s" class is deprecated, use the "%s" class instead.', self::class, ErrorDetailsStamp::class));
39-
}
40-
$this->flattenException = $flattenException;
4128
}
4229

4330
public static function getRetryCountFromEnvelope(Envelope $envelope): int
@@ -53,26 +40,6 @@ public function getRetryCount(): int
5340
return $this->retryCount;
5441
}
5542

56-
/**
57-
* @deprecated since Symfony 5.2, use ErrorDetailsStamp instead.
58-
*/
59-
public function getExceptionMessage(): ?string
60-
{
61-
trigger_deprecation('symfony/messenger', '5.2', sprintf('Using the "getExceptionMessage()" method of the "%s" class is deprecated, use the "%s" class instead.', self::class, ErrorDetailsStamp::class));
62-
63-
return $this->exceptionMessage;
64-
}
65-
66-
/**
67-
* @deprecated since Symfony 5.2, use ErrorDetailsStamp instead.
68-
*/
69-
public function getFlattenException(): ?FlattenException
70-
{
71-
trigger_deprecation('symfony/messenger', '5.2', sprintf('Using the "getFlattenException()" method of the "%s" class is deprecated, use the "%s" class instead.', self::class, ErrorDetailsStamp::class));
72-
73-
return $this->flattenException;
74-
}
75-
7643
public function getRedeliveredAt(): \DateTimeInterface
7744
{
7845
return $this->redeliveredAt;

0 commit comments

Comments
 (0)
0