8000 [FrameworkBundle] Deprecate the messenger.reset_on_message config option by upyx · Pull Request #45705 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Deprecate the messenger.reset_on_message config option #45705

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
Mar 24, 2022
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
8000
Diff view
Diff view
6 changes: 6 additions & 0 deletions UPGRADE-6.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Console
* Add argument `$suggestedValues` to `Command::addArgument` and `Command::addOption`
* Add argument `$suggestedValues` to `InputArgument` and `InputOption` constructors

FrameworkBundle
---------------

* Deprecate the `reset_on_message` config option. It can be set to `true` only and does nothing now.
To prevent services resetting after each message the "--no-reset" option in "messenger:consume" command can be set

HttpKernel
----------

Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG
* Load PHP configuration files by default in the `MicroKernelTrait`
* Add `cache:pool:invalidate-tags` command
* Add `xliff` support in addition to `xlf` for `XliffFileDumper`
* Deprecate the `reset_on_message` config option. It can be set to `true` only and does nothing now

6.0
---
Expand Down
10000
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,7 @@ function ($a) {
->booleanNode('reset_on_message')
->defaultTrue()
->info('Reset container services after each message.')
->setDeprecated('symfony/framework-bundle', '6.1', 'Option "%node%" at "%path%" is deprecated. It does nothing and will be removed in version 7.0.')
->validate()
->ifTrue(static fn ($v) => true !== $v)
->thenInvalid('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.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\Common\Annotations\Annotation;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Log\LoggerAwareInterface;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage;
Expand Down Expand Up @@ -78,6 +79,8 @@

abstract class FrameworkExtensionTest extends TestCase
{
use ExpectDeprecationTrait;

private static $containerCache = [];

abstract protected function loadFromFile(ContainerBuilder $container, $file);
Expand Down Expand Up @@ -709,6 +712,26 @@ public function testMessengerServicesRemovedWhenDisabled()
$this->assertFalse($container->hasDefinition('cache.messenger.restart_workers_signal'));
}

/**
* @group legacy
*/
public function testMessengerWithExplictResetOnMessageLegacy()
{
$this->expectDeprecation('Since symfony/framework-bundle 6.1: Option "reset_on_message" at "framework.messenger" is deprecated. It does nothing and will be removed in version 7.0.');

$container = $this->createContainerFromFile('messenger_with_explict_reset_on_message_legacy');

$this->assertTrue($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->assertTrue($container->hasDefinition('messenger.listener.reset_services'));
$this->assertSame('messenger.listener.reset_services', (string) $container->getDefinition('console.command.messenger_consume_messages')->getArgument(5));
}

public function testMessenger()
{
$container = $this->createContainerFromFile('messenger');
Expand Down Expand Up @@ -969,6 +992,17 @@ public function testMessengerInvalidTransportRouting()
$this->createContainerFromFile('messenger_routing_invalid_transport');
}

/**
* @group legacy
*/
public function testMessengerWithDisabledResetOnMessage()
{
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage('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.');

$this->createContainerFromFile('messenger_with_disabled_reset_on_message');
}

public function testTranslator()
{
$container = $this->createContainerFromFile('full');
Expand Down
0