Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4fe223f

Browse files
committed
feature #45705 [FrameworkBundle] Deprecate the messenger.reset_on_message config option (upyx)
This PR was squashed before being merged into the 6.1 branch. Discussion ---------- [FrameworkBundle] Deprecate the messenger.reset_on_message config option | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | no | New feature? | no | Deprecations? | yes | Tickets | Continues #43203 (comment) | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Commits ------- 6591c8f [FrameworkBundle] Deprecate the messenger.reset_on_message config option
2 parents f5a8916 + 6591c8f commit 4fe223f

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

UPGRADE-6.1.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ Console
1515
* Add argument `$suggestedValues` to `Command::addArgument` and `Command::addOption`
1616
* Add argument `$suggestedValues` to `InputArgument` and `InputOption` constructors
1717

18+
FrameworkBundle
19+
---------------
20+
21+
* Deprecate the `reset_on_message` config option. It can be set to `true` only and does nothing now.
22+
To prevent services resetting after each message the "--no-reset" option in "messenger:consume" command can be set
23+
1824
HttpKernel
1925
----------
2026

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
* Load PHP configuration files by default in the `MicroKernelTrait`
99
* Add `cache:pool:invalidate-tags` command
1010
* Add `xliff` support in addition to `xlf` for `XliffFileDumper`
11+
* Deprecate the `reset_on_message` config option. It can be set to `true` only and does nothing now
1112

1213
6.0
1314
---

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,7 @@ function ($a) {
14261426
->booleanNode('reset_on_message')
14271427
->defaultTrue()
14281428
->info('Reset container services after each message.')
1429+
->setDeprecated('symfony/framework-bundle', '6.1', 'Option "%node%" at "%path%" is deprecated. It does nothing and will be removed in version 7.0.')
14291430
->validate()
14301431
->ifTrue(static fn ($v) => true !== $v)
14311432
->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.')

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\Common\Annotations\Annotation;
1515
use Psr\Cache\CacheItemPoolInterface;
1616
use Psr\Log\LoggerAwareInterface;
17+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1718
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
1819
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
1920
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage;
@@ -78,6 +79,8 @@
7879

7980
abstract class FrameworkExtensionTest extends TestCase
8081
{
82+
use ExpectDeprecationTrait;
83+
8184
private static $containerCache = [];
8285

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

715+
/**
716+
* @group legacy
717+
*/
718+
public function testMessengerWithExplictResetOnMessageLegacy()
719+
{
720+
$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.');
721+
722+
$container = $this->createContainerFromFile('messenger_with_explict_reset_on_message_legacy');
723+
724+
$this->assertTrue($container->hasDefinition('console.command.messenger_consume_messages'));
725+
$this->assertTrue($container->hasAlias('messenger.default_bus'));
726+
$this->assertTrue($container->getAlias('messenger.default_bus')->isPublic());
727+
$this->assertTrue($container->hasDefinition('messenger.transport.amqp.factory'));
728+
$this->assertTrue($container->hasDefinition('messenger.transport.redis.factory'));
729+
$this->assertTrue($container->hasDefinition('messenger.transport_factory'));
730+
$this->assertSame(TransportFactory::class, $container->getDefinition('messenger.transport_factory')->getClass());
731+
$this->assertTrue($container->hasDefinition('messenger.listener.reset_services'));
732+
$this->assertSame('messenger.listener.reset_services', (string) $container->getDefinition('console.command.messenger_consume_messages')->getArgument(5));
733+
}
734+
712735
public function testMessenger()
713736
{
714737
$container = $this->createContainerFromFile('messenger');
@@ -969,6 +992,17 @@ public function testMessengerInvalidTransportRouting()
969992
$this->createContainerFromFile('messenger_routing_invalid_transport');
970993
}
971994

995+
/**
996+
* @group legacy
997+
*/
998+
public function testMessengerWithDisabledResetOnMessage()
999+
{
1000+
$this->expectException(InvalidConfigurationException::class);
1001+
$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.');
1002+
1003+
$this->createContainerFromFile('messenger_with_disabled_reset_on_message');
1004+
}
1005+
9721006
public function testTranslator()
9731007
{
9741008
$container = $this->createContainerFromFile('full');

0 commit comments

Comments
 (0)