From b39b35b95dedb73bbdb2936546c4f7339b077e1d Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Mon, 22 May 2017 18:25:24 +0200 Subject: [PATCH] Prevent auto-registration of UserPasswordEncoderCommand --- .../DependencyInjection/SecurityExtension.php | 8 ++++---- .../DependencyInjection/CompleteConfigurationTest.php | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index a54244d67c66..4191506f1ece 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -98,11 +98,11 @@ public function load(array $configs, ContainerBuilder $container) if ($config['encoders']) { $this->createEncoders($config['encoders'], $container); + } - if (class_exists(Application::class)) { - $loader->load('console.xml'); - $container->getDefinition('security.console.user_password_encoder_command')->replaceArgument(1, array_keys($config['encoders'])); - } + if (class_exists(Application::class)) { + $loader->load('console.xml'); + $container->getDefinition('security.console.user_password_encoder_command')->replaceArgument(1, array_keys($config['encoders'])); } // load ACL diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index bfa0f1b877b2..6ef0e305ec4f 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -345,6 +345,11 @@ public function testUserCheckerConfigWithNoCheckers() $this->assertEquals('security.user_checker', $this->getContainer('container1')->getAlias('security.user_checker.secure')); } + public function testUserPasswordEncoderCommandIsRegistered() + { + $this->assertTrue($this->getContainer('remember_me_options')->has('security.console.user_password_encoder_command')); + } + protected function getContainer($file) { $file = $file.'.'.$this->getFileExtension();