8000 bug #32792 [Messenger] Fix incompatibility with FrameworkBundle <4.3.… · symfony/symfony@b13e6af · GitHub
[go: up one dir, main page]

Skip to content

Commit b13e6af

Browse files
committed
bug #32792 [Messenger] Fix incompatibility with FrameworkBundle <4.3.1 (chalasr)
This PR was merged into the 4.3 branch. Discussion ---------- [Messenger] Fix incompatibility with FrameworkBundle <4.3.1 | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32738 | License | MIT | Doc PR | - Aims to fix an edge case where you install (or upgrade to) symfony/messenger >=4.3.1 while having symfony/framework-bundle <4.3.1 installed. Commits ------- 5d73970 [Messenger] Fix incompatibility with FrameworkBundle <4.3.1
2 parents c674042 + 5d73970 commit b13e6af

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
</service>
8383

8484
<service id="console.command.messenger_consume_messages" class="Symfony\Component\Messenger\Command\ConsumeMessagesCommand">
85-
<argument type="service" id="messenger.routable_message_bus" />
85+
<argument /> <!-- Routable message bus -->
8686
<argument type="service" id="messenger.receiver_locator" />
8787
<argument type="service" id="logger" on-invalid="null" />
8888
<argument type="collection" /> <!-- Receiver names -->

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public function __construct($routableBus, ContainerInterface $receiverLocator, L
5757
// to be deprecated in 4.4
5858
if ($routableBus instanceof ContainerInterface) {
5959
$routableBus = new RoutableMessageBus($routableBus);
60+
} elseif (!$routableBus instanceof RoutableMessageBus) {
61+
throw new \TypeError(sprintf('The first argument must be an instance of "%s".', RoutableMessageBus::class));
6062
}
6163

6264
if (\is_array($retryStrategyLocator)) {

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,19 @@ private function registerReceivers(ContainerBuilder $container, array $busIds)
253253
$buses[$busId] = new Reference($busId);
254254
}
255255

256-
if ($container->hasDefinition('messenger.routable_message_bus')) {
256+
if ($hasRoutableMessageBus = $container->hasDefinition('messenger.routable_message_bus')) {
257257
$container->getDefinition('messenger.routable_message_bus')
258258
->replaceArgument(0, ServiceLocatorTagPass::register($container, $buses));
259259
}
260260

261261
if ($container->hasDefinition('console.command.messenger_consume_messages')) {
262-
$container->getDefinition('console.command.messenger_consume_messages')
263-
->replaceArgument(3, array_values($receiverNames));
262+
$consumeCommandDefinition = $container->getDefinition('console.command.messenger_consume_messages');
263+
264+
if ($hasRoutableMessageBus) {
265+
$consumeCommandDefinition->replaceArgument(0, new Reference('messenger.routable_message_bus'));
266+
}
267+
268+
$consumeCommandDefinition->replaceArgument(3, array_values($receiverNames));
264269
}
265270

266271
if ($container->hasDefinition('console.command.messenger_setup_transports')) {

0 commit comments

Comments
 (0)
0