Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix framework configuration when messenger uses without console #43202

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 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
1 change: 1 addition & 0 deletions 1 UPGRADE-5.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Messenger

* Deprecate not setting the `delete_after_ack` config option (or DSN parameter) using the Redis transport,
its default value will change to `true` in 6.0
* Deprecate not setting the `reset_on_message` config option, its default value will change to `true` in 6.0

SecurityBundle
--------------
Expand Down
1 change: 1 addition & 0 deletions 1 UPGRADE-6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ Messenger
* Removed the `prefetch_count` parameter in the AMQP bridge.
* Removed the use of TLS option for Redis Bridge, use `rediss://127.0.0.1` instead of `redis://127.0.0.1?tls=1`
* The `delete_after_ack` config option of the Redis transport now defaults to `true`
* The `reset_on_message` config option now defaults to `true`

Mime
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function load(array $configs, ContainerBuilder $container)

$container->registerAliasForArgument('parameter_bag', PsrContainerInterface::class);

if (class_exists(Application::class)) {
if ($this->hasConsole()) {
$loader->load('console.php');

if (!class_exists(BaseXliffLintCommand::class)) {
Expand Down Expand Up @@ -599,6 +599,11 @@ public function getConfiguration(array $config, ContainerBuilder $container)
return new Configuration($container->getParameter('kernel.debug'));
}

protected function hasConsole(): bool
{
return class_exists(Application::class);
}

private function registerFormConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader)
{
$loader->load('form.php');
Expand Down Expand Up @@ -2081,7 +2086,9 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
throw new LogicException('The "framework.messenger.reset_on_message" configuration option can be set to "true" only. To prevent services resetting after each message you can set the "--no-reset" option in "messenger:consume" command.');
}

if (null === $config['reset_on_message']) {
if (!$container->hasDefinition('console.command.messenger_consume_messages')) {
$container->removeDefinition('messenger.listener.reset_services');
} elseif (null === $config['reset_on_message']) {
trigger_deprecation('symfony/framework-bundle', '5.4', 'Not setting the "framework.messenger.reset_on_message" configuration option is deprecated, it will default to "true" in version 6.0.');

$container->getDefinition('console.command.messenger_consume_messages')->replaceArgument(5, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@
->set('messenger.listener.reset_services', ResetServicesListener::class)
->args([
service('services_resetter'),
abstract_arg('receivers names'),
])

->set('messenger.routable_message_bus', RoutableMessageBus::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,25 @@ public function testMessenger()
$this->assertSame('messenger.listener.reset_services', (string) $container->getDefinition('console.command.messenger_consume_messages')->getArgument(5));
}

public function testMessengerWithoutConsole()
{
$extension = $this->createPartialMock(FrameworkExtension::class, ['hasConsole', 'getAlias']);
$extension->method('hasConsole')->willReturn(false);
$extension->method('getAlias')->willReturn((new FrameworkExtension())->getAlias());

$container = $this->createContainerFromFile('messenger', [], true, false, $extension);
$container->compile();

$this->assertFalse($container->hasDefinition('console.command.messenger_consume_messages'));
$this->assertTrue($container->hasAlias('messenger.default_bus'));
$this->assertTrue($container->getAlias('messenger.default_bus')->isPublic());
$this->assertTrue($container->hasDefinition('messenger.transport.amqp.factory'));
$this->assertTrue($container->hasDefinition('messenger.transport.redis.factory'));
$this->assertTrue($container->hasDefinition('messenger.transport_factory'));
$this->assertSame(TransportFactory::class, $container->getDefinition('messenger.transport_factory')->getClass());
$this->assertFalse($container->hasDefinition('messenger.listener.reset_services'));
}

public function testMessengerMultipleFailureTransports()
{
$container = $this->createContainerFromFile('messenger_multiple_failure_transports');
Expand Down Expand Up @@ -1960,14 +1979,14 @@ protected function createContainer(array $data = [])
], $data)));
}

protected function createContainerFromFile($file, $data = [], $resetCompilerPasses = true, $compile = true)
protected function createContainerFromFile($file, $data = [], $resetCompilerPasses = true, $compile = true, FrameworkExtension $extension = null)
{
$cacheKey = md5(static::class.$file.serialize($data));
if ($compile && isset(self::$containerCache[$cacheKey])) {
return self::$containerCache[$cacheKey];
}
$container = $this->createContainer($data);
$container->registerExtension(new FrameworkExtension());
$container->registerExtension($extension ?: new FrameworkExtension());
$this->loadFromFile($container, $file);

if ($resetCompilerPasses) {
Expand Down
1 change: 1 addition & 0 deletions 1 src/Symfony/Component/Messenger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG
* Add support for resetting container services after each messenger message.
* Added `WorkerMetadata` class which allows you to access the configuration details of a worker, like `queueNames` and `transportNames` it consumes from.
* New method `getMetadata()` was added to `Worker` class which returns the `WorkerMetadata` object.
* Deprecate not setting the `reset_on_message` config option, its default value will change to `true` in 6.0

5.3
---
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.