From da202feb71a97b519c24891b2576b255db7823dd Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Thu, 18 May 2017 07:25:38 +0200 Subject: [PATCH] [SecurityBundle][Security][Finder] Remove deprecated code paths - [Finder] Removed `ExceptionInterface` - [SecurityBundle] remove `UserPasswordEncoderCommand` BC layer - [Security] remove `LogoutUrlGenerator::registerListener` BC layer --- .../Bundle/SecurityBundle/CHANGELOG.md | 2 ++ .../Command/UserPasswordEncoderCommand.php | 30 +++---------------- .../UserPasswordEncoderCommandTest.php | 22 -------------- src/Symfony/Component/Finder/CHANGELOG.md | 5 ++++ .../Finder/Exception/ExceptionInterface.php | 25 ---------------- src/Symfony/Component/Security/CHANGELOG.md | 5 ++++ .../Http/Logout/LogoutUrlGenerator.php | 15 +--------- 7 files changed, 17 insertions(+), 87 deletions(-) delete mode 100644 src/Symfony/Component/Finder/Exception/ExceptionInterface.php diff --git a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md index c3a6336c44ac8..468b053b7646c 100644 --- a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md @@ -6,6 +6,8 @@ CHANGELOG * removed `FirewallContext::getContext()` * made `FirewallMap::$container` and `::$map` private + * made the first `UserPasswordEncoderCommand::_construct()` argument mandatory + * `UserPasswordEncoderCommand` does not extend `ContainerAwareCommand` anymore 3.3.0 ----- diff --git a/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php b/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php index a588bdd331e96..c307dca1f7871 100644 --- a/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php +++ b/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php @@ -11,7 +11,7 @@ namespace Symfony\Bundle\SecurityBundle\Command; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -19,43 +19,27 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder; use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; -use Symfony\Component\Security\Core\User\User; /** * Encode a user's password. * * @author Sarah Khalil */ -class UserPasswordEncoderCommand extends ContainerAwareCommand +class UserPasswordEncoderCommand extends Command { private $encoderFactory; private $userClasses; - public function __construct(EncoderFactoryInterface $encoderFactory = null, array $userClasses = array()) + public function __construct(EncoderFactoryInterface $encoderFactory, array $userClasses = array()) { - if (null === $encoderFactory) { - @trigger_error(sprintf('Passing null as the first argument of "%s" is deprecated since version 3.3 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED); - } - $this->encoderFactory = $encoderFactory; $this->userClasses = $userClasses; parent::__construct(); } - /** - * {@inheritdoc} - */ - protected function getContainer() - { - @trigger_error(sprintf('Method "%s" is deprecated since version 3.3 and "%s" won\'t implement "%s" anymore in 4.0.', __METHOD__, __CLASS__, ContainerAwareInterface::class), E_USER_DEPRECATED); - - return parent::getContainer(); - } - /** * {@inheritdoc} */ @@ -123,8 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $userClass = $this->getUserClass($input, $io); $emptySalt = $input->getOption('empty-salt'); - $encoderFactory = $this->encoderFactory ?: parent::getContainer()->get('security.encoder_factory'); - $encoder = $encoderFactory->getEncoder($userClass); + $encoder = $this->encoderFactory->getEncoder($userClass); $bcryptWithoutEmptySalt = !$emptySalt && $encoder instanceof BCryptPasswordEncoder; if ($bcryptWithoutEmptySalt) { @@ -206,11 +189,6 @@ private function getUserClass(InputInterface $input, SymfonyStyle $io) } if (empty($this->userClasses)) { - if (null === $this->encoderFactory) { - // BC to be removed and simply keep the exception whenever there is no configured user classes in 4.0 - return User::class; - } - throw new \RuntimeException('There are no configured encoders for the "security" extension.'); } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php index 0710f94b5b094..f7360a1effcd2 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php @@ -193,28 +193,6 @@ public function testThrowsExceptionOnNoConfiguredEncoders() ), array('interactive' => false)); } - /** - * @group legacy - * @expectedDeprecation Passing null as the first argument of "Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand::__construct" is deprecated since version 3.3 and will be removed in 4.0. If the command was registered by convention, make it a service instead. - */ - public function testLegacy() - { - $application = new ConsoleApplication(); - $application->add(new UserPasswordEncoderCommand()); - - $passwordEncoderCommand = $application->find('security:encode-password'); - self::bootKernel(array('test_case' => 'PasswordEncode')); - $passwordEncoderCommand->setContainer(self::$kernel->getContainer()); - - $tester = new CommandTester($passwordEncoderCommand); - $tester->execute(array( - 'command' => 'security:encode-password', - 'password' => 'password', - ), array('interactive' => false)); - - $this->assertContains('Encoder used Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder', $tester->getDisplay()); - } - protected function setUp() { putenv('COLUMNS='.(119 + strlen(PHP_EOL))); diff --git a/src/Symfony/Component/Finder/CHANGELOG.md b/src/Symfony/Component/Finder/CHANGELOG.md index cf19de6930ed5..7c81389390374 100644 --- a/src/Symfony/Component/Finder/CHANGELOG.md +++ b/src/Symfony/Component/Finder/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +4.0.0 +----- + + * removed `ExceptionInterface` + 3.3.0 ----- diff --git a/src/Symfony/Component/Finder/Exception/ExceptionInterface.php b/src/Symfony/Component/Finder/Exception/ExceptionInterface.php deleted file mode 100644 index 161e9686d2b70..0000000000000 --- a/src/Symfony/Component/Finder/Exception/ExceptionInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Finder\Exception; - -/** - * @author Jean-François Simon - * - * @deprecated since 3.3, to be removed in 4.0. - */ -interface ExceptionInterface -{ - /** - * @return \Symfony\Component\Finder\Adapter\AdapterInterface - */ - public function getAdapter(); -} diff --git a/src/Symfony/Component/Security/CHANGELOG.md b/src/Symfony/Component/Security/CHANGELOG.md index 69cdd285282fa..a8ec0d017e026 100644 --- a/src/Symfony/Component/Security/CHANGELOG.md +++ b/src/Symfony/Component/Security/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +4.0.0 +----- + + * added a sixth `string $context` argument to`LogoutUrlGenerator::registerListener()` + 3.3.0 ----- diff --git a/src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php b/src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php index 3f2def8d735cc..9bda9816ba11c 100644 --- a/src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php +++ b/src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php @@ -48,21 +48,8 @@ public function __construct(RequestStack $requestStack = null, UrlGeneratorInter * @param CsrfTokenManagerInterface|null $csrfTokenManager A CsrfTokenManagerInterface instance * @param string|null $context The listener context */ - public function registerListener($key, $logoutPath, $csrfTokenId, $csrfParameter, CsrfTokenManagerInterface $csrfTokenManager = null/*, string $context = null*/) + public function registerListener($key, $logoutPath, $csrfTokenId, $csrfParameter, CsrfTokenManagerInterface $csrfTokenManager = null, string $context = null) { - if (func_num_args() >= 6) { - $context = func_get_arg(5); - } else { - if (__CLASS__ !== get_class($this)) { - $r = new \ReflectionMethod($this, __FUNCTION__); - if (__CLASS__ !== $r->getDeclaringClass()->getName()) { - @trigger_error(sprintf('Method %s() will have a sixth `string $context = null` argument in version 4.0. Not defining it is deprecated since 3.3.', __METHOD__), E_USER_DEPRECATED); - } - } - - $context = null; - } - $this->listeners[$key] = array($logoutPath, $csrfTokenId, $csrfParameter, $csrfTokenManager, $context); }