From 45dd40cde8fa19a568f40026ea55987d78037531 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 28 Sep 2017 18:40:37 +0200 Subject: [PATCH] remove deprecated features --- .../Bundle/SecurityBundle/CHANGELOG.md | 3 ++ .../DependencyInjection/MainConfiguration.php | 4 +- .../DependencyInjection/SecurityExtension.php | 11 +--- .../SecurityExtensionTest.php | 54 +------------------ .../DependencyInjection/CHANGELOG.md | 43 +++++++++++++++ .../Compiler/AutowirePass.php | 45 ---------------- .../Loader/YamlFileLoader.php | 8 --- .../Tests/Compiler/AutowirePassTest.php | 39 ++------------ src/Symfony/Component/Filesystem/CHANGELOG.md | 1 + .../Exception/InvalidArgumentException.php | 19 +++++++ .../Component/Filesystem/Filesystem.php | 9 +++- .../Filesystem/Tests/FilesystemTest.php | 32 ++++------- .../Component/HttpKernel/Tests/KernelTest.php | 1 - .../Routing/Loader/YamlFileLoader.php | 8 --- .../Http/Firewall/ContextListener.php | 14 ++--- .../Tests/Firewall/ContextListenerTest.php | 18 +------ .../Translation/Loader/YamlFileLoader.php | 8 --- .../Mapping/Loader/YamlFileLoader.php | 8 --- 18 files changed, 97 insertions(+), 228 deletions(-) create mode 100644 src/Symfony/Component/Filesystem/Exception/InvalidArgumentException.php diff --git a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md index 698d54011000d..1789357b85162 100644 --- a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md @@ -14,6 +14,9 @@ CHANGELOG * removed command `init:acl` along with `InitAclCommand` class * removed `acl` configuration key and related services, use symfony/acl-bundle instead * removed auto picking the first registered provider when no configured provider on a firewall and ambiguous + * the firewall option `logout_on_user_change` is now always true, which will trigger a logout if the user changes + between requests + * the `switch_user.stateless` firewall option is `true` for stateless firewalls 3.4.0 ----- diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php index c0527dc716069..716d05a43d30b 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php @@ -202,8 +202,8 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto ->booleanNode('stateless')->defaultFalse()->end() ->scalarNode('context')->cannotBeEmpty()->end() ->booleanNode('logout_on_user_change') - ->defaultFalse() - ->info('When true, it will trigger a logout for the user if something has changed. This will be the default behavior as of Syfmony 4.0.') + ->defaultTrue() + ->info('When true, it will trigger a logout for the user if something has changed.') ->end() ->arrayNode('logout') ->treatTrueLike(array()) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 2b886d93a998a..0f1e21a5af740 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -188,10 +188,6 @@ private function createFirewalls($config, ContainerBuilder $container) $customUserChecker = true; } - if (!isset($firewall['logout_on_user_change']) || !$firewall['logout_on_user_change']) { - @trigger_error('Setting logout_on_user_change to false is deprecated as of 3.4 and will always be true in 4.0. Set logout_on_user_change to true in your firewall configuration.', E_USER_DEPRECATED); - } - $contextListenerDefinition->addMethodCall('setLogoutOnUserChange', array($firewall['logout_on_user_change'])); $configId = 'security.firewall.map.config.'.$name; @@ -610,11 +606,6 @@ private function createSwitchUserListener($container, $id, $config, $defaultProv { $userProvider = isset($config['provider']) ? $this->getUserProviderId($config['provider']) : $defaultProvider; - // in 4.0, ignore the `switch_user.stateless` key if $stateless is `true` - if ($stateless && false === $config['stateless']) { - @trigger_error(sprintf('Firewall "%s" is configured as "stateless" but the "switch_user.stateless" key is set to false. Both should have the same value, the firewall\'s "stateless" value will be used as default value for the "switch_user.stateless" key in 4.0.', $id), E_USER_DEPRECATED); - } - $switchUserListenerId = 'security.authentication.switchuser_listener.'.$id; $listener = $container->setDefinition($switchUserListenerId, new ChildDefinition('security.authentication.switchuser_listener')); $listener->replaceArgument(1, new Reference($userProvider)); @@ -622,7 +613,7 @@ private function createSwitchUserListener($container, $id, $config, $defaultProv $listener->replaceArgument(3, $id); $listener->replaceArgument(6, $config['parameter']); $listener->replaceArgument(7, $config['role']); - $listener->replaceArgument(9, $config['stateless']); + $listener->replaceArgument(9, $stateless ?: $config['stateless']); return $switchUserListenerId; } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php index 18821f9aedd36..71171ae4f5d7f 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php @@ -123,35 +123,6 @@ public function testDisableRoleHierarchyVoter() $this->assertFalse($container->hasDefinition('security.access.role_hierarchy_voter')); } - /** - * @group legacy - * @expectedDeprecation Setting logout_on_user_change to false is deprecated as of 3.4 and will always be true in 4.0. Set logout_on_user_change to true in your firewall configuration. - */ - public function testDeprecationForUserLogout() - { - $container = $this->getRawContainer(); - - $container->loadFromExtension('security', array( - 'providers' => array( - 'default' => array('id' => 'foo'), - ), - - 'firewalls' => array( - 'some_firewall' => array( - 'pattern' => '/.*', - 'http_basic' => null, - 'logout_on_user_change' => false, - ), - ), - )); - - $container->compile(); - } - - /** - * @group legacy - * @expectedDeprecation Firewall "some_firewall" is configured as "stateless" but the "switch_user.stateless" key is set to false. Both should have the same value, the firewall's "stateless" value will be used as default value for the "switch_user.stateless" key in 4.0. - */ public function testSwitchUserNotStatelessOnStatelessFirewall() { $container = $this->getRawContainer(); @@ -172,31 +143,8 @@ public function testSwitchUserNotStatelessOnStatelessFirewall() )); $container->compile(); - } - /** - * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException - * @expectedExceptionMessage Not configuring explicitly the provider on "default" firewall is ambiguous as there is more than one registered provider. - */ - public function testDeprecationForAmbiguousProvider() - { - $container = $this->getRawContainer(); - - $container->loadFromExtension('security', array( - 'providers' => array( - 'first' => array('id' => 'foo'), - 'second' => array('id' => 'bar'), - ), - - 'firewalls' => array( - 'default' => array( - 'http_basic' => null, - 'logout_on_user_change' => true, - ), - ), - )); - - $container->compile(); + $this->assertTrue($container->getDefinition('security.authentication.switchuser_listener.some_firewall')->getArgument(9)); } protected function getRawContainer() diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md index ca437e2cf6701..43a41fa621c88 100644 --- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -4,6 +4,49 @@ CHANGELOG 4.0.0 ----- + * Relying on service auto-registration while autowiring is not supported anymore. + Explicitly inject your dependencies or create services whose ids are + their fully-qualified class name. + + Before: + + ```php + namespace App\Controller; + + use App\Mailer; + + class DefaultController + { + public function __construct(Mailer $mailer) { + // ... + } + + // ... + } + ``` + ```yml + services: + App\Controller\DefaultController: + autowire: true + ``` + + After: + + ```php + // same PHP code + ``` + ```yml + services: + App\Controller\DefaultController: + autowire: true + + # or + # App\Controller\DefaultController: + # arguments: { $mailer: "@App\Mailer" } + + App\Mailer: + autowire: true + ``` * removed autowiring services based on the types they implement * added a third `$methodName` argument to the `getProxyFactoryCode()` method of the `DumperInterface` diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 1b099e0ac8885..ec3baa974057c 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -253,8 +253,6 @@ private function getAutowiredReference(TypedReference $reference, $deprecationMe if (isset($this->autowired[$type])) { return $this->autowired[$type] ? new TypedReference($this->autowired[$type], $type) : null; } - - return $this->createAutowiredDefinition($type); } /** @@ -325,49 +323,6 @@ private function set($type, $id) $this->ambiguousServiceTypes[$type][] = $id; } - /** - * Registers a definition for the type if possible or throws an exception. - * - * @param string $type - * - * @return TypedReference|null A reference to the registered definition - */ - private function createAutowiredDefinition($type) - { - if (!($typeHint = $this->container->getReflectionClass($type, false)) || !$typeHint->isInstantiable()) { - return; - } - - $currentId = $this->currentId; - $this->currentId = $type; - $this->autowired[$type] = $argumentId = sprintf('autowired.%s', $type); - $argumentDefinition = new Definition($type); - $argumentDefinition->setPublic(false); - $argumentDefinition->setAutowired(true); - - try { - $originalThrowSetting = $this->throwOnAutowiringException; - $this->throwOnAutowiringException = true; - $this->processValue($argumentDefinition, true); - $this->container->setDefinition($argumentId, $argumentDefinition); - } catch (AutowiringFailedException $e) { - $this->autowired[$type] = false; - $this->lastFailure = $e->getMessage(); - $this->container->log($this, $this->lastFailure); - - return; - } finally { - $this->throwOnAutowiringException = $originalThrowSetting; - $this->currentId = $currentId; - } - - @trigger_error(sprintf('Relying on service auto-registration for type "%s" is deprecated since version 3.4 and won\'t be supported in 4.0. Create a service named "%s" instead.', $type, $type), E_USER_DEPRECATED); - - $this->container->log($this, sprintf('Type "%s" has been auto-registered for service "%s".', $type, $this->currentId)); - - return new TypedReference($argumentId, $type); - } - private function createTypeNotFoundMessage(TypedReference $reference, $label) { if (!$r = $this->container->getReflectionClass($type = $reference->getType(), false)) { diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 39e2c9ca5b269..d3b261d57b177 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -636,18 +636,10 @@ protected function loadFile($file) $this->yamlParser = new YamlParser(); } - $prevErrorHandler = set_error_handler(function ($level, $message, $script, $line) use ($file, &$prevErrorHandler) { - $message = E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$file.'"$0', $message) : $message; - - return $prevErrorHandler ? $prevErrorHandler($level, $message, $script, $line) : false; - }); - try { $configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS); } catch (ParseException $e) { throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $file), 0, $e); - } finally { - restore_error_handler(); } return $this->validate($configuration, $file); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index c47d813220973..d28a5e613930a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -247,11 +247,10 @@ public function testWithTypeSet() } /** - * @group legacy - * @expectedDeprecation Relying on service auto-registration for type "Symfony\Component\DependencyInjection\Tests\Compiler\Lille" is deprecated since version 3.4 and won't be supported in 4.0. Create a service named "Symfony\Component\DependencyInjection\Tests\Compiler\Lille" instead. - * @expectedDeprecation Relying on service auto-registration for type "Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas" is deprecated since version 3.4 and won't be supported in 4.0. Create a service named "Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas" instead. + * @expectedException \Symfony\Component\DependencyInjection\Exception\AutowiringFailedException + * @expectedExceptionMessage Cannot autowire service "coop_tilleuls": argument "$j" of method "Symfony\Component\DependencyInjection\Tests\Compiler\LesTilleuls::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas" but no such service exists. */ - public function testCreateDefinition() + public function testServicesAreNotAutoCreated() { $container = new ContainerBuilder(); @@ -260,19 +259,6 @@ public function testCreateDefinition() $pass = new AutowirePass(); $pass->process($container); - - $this->assertCount(2, $container->getDefinition('coop_tilleuls')->getArguments()); - $this->assertEquals('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas', $container->getDefinition('coop_tilleuls')->getArgument(0)); - $this->assertEquals('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas', $container->getDefinition('coop_tilleuls')->getArgument(1)); - - $dunglasDefinition = $container->getDefinition('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas'); - $this->assertEquals(__NAMESPACE__.'\Dunglas', $dunglasDefinition->getClass()); - $this->assertFalse($dunglasDefinition->isPublic()); - $this->assertCount(1, $dunglasDefinition->getArguments()); - $this->assertEquals('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Lille', $dunglasDefinition->getArgument(0)); - - $lilleDefinition = $container->getDefinition('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Lille'); - $this->assertEquals(__NAMESPACE__.'\Lille', $lilleDefinition->getClass()); } public function testResolveParameter() @@ -563,25 +549,6 @@ public function testExplicitMethodInjection() ); } - /** - * @group legacy - * @expectedDeprecation Relying on service auto-registration for type "Symfony\Component\DependencyInjection\Tests\Compiler\A" is deprecated since version 3.4 and won't be supported in 4.0. Create a service named "Symfony\Component\DependencyInjection\Tests\Compiler\A" instead. - */ - public function testTypedReference() - { - $container = new ContainerBuilder(); - - $container - ->register('bar', Bar::class) - ->setProperty('a', array(new TypedReference(A::class, A::class, Bar::class))) - ; - - $pass = new AutowirePass(); - $pass->process($container); - - $this->assertSame(A::class, $container->getDefinition('autowired.'.A::class)->getClass()); - } - public function getCreateResourceTests() { return array( diff --git a/src/Symfony/Component/Filesystem/CHANGELOG.md b/src/Symfony/Component/Filesystem/CHANGELOG.md index 901d18a3e5cdc..9f1f817e753dd 100644 --- a/src/Symfony/Component/Filesystem/CHANGELOG.md +++ b/src/Symfony/Component/Filesystem/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG ----- * removed `LockHandler` + * Support for passing relative paths to `Filesystem::makePathRelative()` has been removed. 3.4.0 ----- diff --git a/src/Symfony/Component/Filesystem/Exception/InvalidArgumentException.php b/src/Symfony/Component/Filesystem/Exception/InvalidArgumentException.php new file mode 100644 index 0000000000000..abadc20029763 --- /dev/null +++ b/src/Symfony/Component/Filesystem/Exception/InvalidArgumentException.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Filesystem\Exception; + +/** + * @author Christian Flothmann + */ +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface +{ +} diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 3a8cae3eacb75..cacda17f899c5 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Filesystem; +use Symfony\Component\Filesystem\Exception\InvalidArgumentException; use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Exception\FileNotFoundException; @@ -450,8 +451,12 @@ public function readlink($path, $canonicalize = false) */ public function makePathRelative($endPath, $startPath) { - if (!$this->isAbsolutePath($endPath) || !$this->isAbsolutePath($startPath)) { - @trigger_error(sprintf('Support for passing relative paths to %s() is deprecated since version 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); + if (!$this->isAbsolutePath($startPath)) { + throw new InvalidArgumentException(sprintf('The start path "%s" is not absolute.', $startPath)); + } + + if (!$this->isAbsolutePath($endPath)) { + throw new InvalidArgumentException(sprintf('The end path "%s" is not absolute.', $endPath)); } // Normalize separators on Windows diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index c72b9a2c4c9a6..4733660a38a2d 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -1141,33 +1141,21 @@ public function providePathsForMakePathRelative() } /** - * @group legacy - * @dataProvider provideLegacyPathsForMakePathRelativeWithRelativePaths - * @expectedDeprecation Support for passing relative paths to Symfony\Component\Filesystem\Filesystem::makePathRelative() is deprecated since version 3.4 and will be removed in 4.0. + * @expectedException \Symfony\Component\Filesystem\Exception\InvalidArgumentException + * @expectedExceptionMessage The start path "var/lib/symfony/src/Symfony/Component" is not absolute. */ - public function testMakePathRelativeWithRelativePaths($endPath, $startPath, $expectedPath) + public function testMakePathRelativeWithRelativeStartPath() { - $path = $this->filesystem->makePathRelative($endPath, $startPath); - - $this->assertEquals($expectedPath, $path); + $this->assertSame('../../../', $this->filesystem->makePathRelative('/var/lib/symfony/', 'var/lib/symfony/src/Symfony/Component')); } - public function provideLegacyPathsForMakePathRelativeWithRelativePaths() + /** + * @expectedException \Symfony\Component\Filesystem\Exception\InvalidArgumentException + * @expectedExceptionMessage The end path "var/lib/symfony/" is not absolute. + */ + public function testMakePathRelativeWithRelativeEndPath() { - return array( - array('usr/lib/symfony/', 'var/lib/symfony/src/Symfony/Component', '../../../../../../usr/lib/symfony/'), - array('aa/bb', 'aa/cc', '../bb/'), - array('aa/cc', 'bb/cc', '../../aa/cc/'), - array('aa/bb', 'aa/./cc', '../bb/'), - array('aa/./bb', 'aa/cc', '../bb/'), - array('aa/./bb', 'aa/./cc', '../bb/'), - array('../../', '../../', './'), - array('../aa/bb/', 'aa/bb/', '../../../aa/bb/'), - array('../../../', '../../', '../'), - array('', '', './'), - array('', 'aa/', '../'), - array('aa/', '', 'aa/'), - ); + $this->assertSame('../../../', $this->filesystem->makePathRelative('var/lib/symfony/', '/var/lib/symfony/src/Symfony/Component')); } public function testMirrorCopiesFilesAndDirectoriesRecursively() diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 352e71f4bdc2d..5b259e7ff66eb 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -415,7 +415,6 @@ public function testLocateResourceOnDirectories() } /** - * @group legacy * @expectedException \LogicException * @expectedExceptionMessage Trying to register two bundles with the same name "DuplicateName" */ diff --git a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php index 037d581d05eab..f3072c927b73e 100644 --- a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -57,18 +57,10 @@ public function load($file, $type = null) $this->yamlParser = new YamlParser(); } - $prevErrorHandler = set_error_handler(function ($level, $message, $script, $line) use ($file, &$prevErrorHandler) { - $message = E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$file.'"$0', $message) : $message; - - return $prevErrorHandler ? $prevErrorHandler($level, $message, $script, $line) : false; - }); - try { $parsedConfig = $this->yamlParser->parseFile($path); } catch (ParseException $e) { throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e); - } finally { - restore_error_handler(); } $collection = new RouteCollection(); diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 553246ed8f0cf..7c762032aa151 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -43,7 +43,7 @@ class ContextListener implements ListenerInterface private $dispatcher; private $registered; private $trustResolver; - private $logoutOnUserChange = false; + private $logoutOnUserChange = true; /** * @param TokenStorageInterface $tokenStorage @@ -74,7 +74,7 @@ public function __construct(TokenStorageInterface $tokenStorage, iterable $userP */ public function setLogoutOnUserChange($logoutOnUserChange) { - $this->logoutOnUserChange = (bool) $logoutOnUserChange; + // no-op, method to be deprecated in 4.1 } /** @@ -183,15 +183,11 @@ protected function refreshUser(TokenInterface $token) // tokens can be deauthenticated if the user has been changed. if (!$token->isAuthenticated()) { - if ($this->logoutOnUserChange) { - if (null !== $this->logger) { - $this->logger->debug('Token was deauthenticated after trying to refresh it.', array('username' => $refreshedUser->getUsername(), 'provider' => get_class($provider))); - } - - return null; + if (null !== $this->logger) { + $this->logger->debug('Token was deauthenticated after trying to refresh it.', array('username' => $refreshedUser->getUsername(), 'provider' => get_class($provider))); } - @trigger_error('Refreshing a deauthenticated user is deprecated as of 3.4 and will trigger a logout in 4.0.', E_USER_DEPRECATED); + return null; } if (null !== $this->logger) { diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php index d27569fa3a0ba..bb80cc25ab017 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ContextListenerTest.php @@ -249,24 +249,11 @@ public function testHandleRemovesTokenIfNoPreviousSessionWasFound() $listener->handle($event); } - /** - * @group legacy - * @expectedDeprecation Refreshing a deauthenticated user is deprecated as of 3.4 and will trigger a logout in 4.0. - */ - public function testIfTokenIsDeauthenticatedTriggersDeprecations() - { - $tokenStorage = new TokenStorage(); - $refreshedUser = new User('foobar', 'baz'); - $this->handleEventWithPreviousSession($tokenStorage, array(new NotSupportingUserProvider(), new SupportingUserProvider($refreshedUser))); - - $this->assertSame($refreshedUser, $tokenStorage->getToken()->getUser()); - } - public function testIfTokenIsDeauthenticated() { $tokenStorage = new TokenStorage(); $refreshedUser = new User('foobar', 'baz'); - $this->handleEventWithPreviousSession($tokenStorage, array(new NotSupportingUserProvider(), new SupportingUserProvider($refreshedUser)), null, true); + $this->handleEventWithPreviousSession($tokenStorage, array(new NotSupportingUserProvider(), new SupportingUserProvider($refreshedUser))); $this->assertNull($tokenStorage->getToken()); } @@ -342,7 +329,7 @@ protected function runSessionOnKernelResponse($newToken, $original = null) return $session; } - private function handleEventWithPreviousSession(TokenStorageInterface $tokenStorage, $userProviders, UserInterface $user = null, $logoutOnUserChange = false) + private function handleEventWithPreviousSession(TokenStorageInterface $tokenStorage, $userProviders, UserInterface $user = null) { $user = $user ?: new User('foo', 'bar'); $session = new Session(new MockArraySessionStorage()); @@ -353,7 +340,6 @@ private function handleEventWithPreviousSession(TokenStorageInterface $tokenStor $request->cookies->set('MOCKSESSID', true); $listener = new ContextListener($tokenStorage, $userProviders, 'context_key'); - $listener->setLogoutOnUserChange($logoutOnUserChange); $listener->handle(new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST)); } } diff --git a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php index 07914f263155c..874fa3a8943e8 100644 --- a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php @@ -38,18 +38,10 @@ protected function loadResource($resource) $this->yamlParser = new YamlParser(); } - $prevErrorHandler = set_error_handler(function ($level, $message, $script, $line) use ($resource, &$prevErrorHandler) { - $message = E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$resource.'"$0', $message) : $message; - - return $prevErrorHandler ? $prevErrorHandler($level, $message, $script, $line) : false; - }); - try { $messages = $this->yamlParser->parseFile($resource); } catch (ParseException $e) { throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s"', $resource), 0, $e); - } finally { - restore_error_handler(); } return $messages; diff --git a/src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php index a213b292acaae..e5e84c38c35dd 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php @@ -115,18 +115,10 @@ protected function parseNodes(array $nodes) */ private function parseFile($path) { - $prevErrorHandler = set_error_handler(function ($level, $message, $script, $line) use ($path, &$prevErrorHandler) { - $message = E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$path.'"$0', $message) : $message; - - return $prevErrorHandler ? $prevErrorHandler($level, $message, $script, $line) : false; - }); - try { $classes = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT); } catch (ParseException $e) { throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e); - } finally { - restore_error_handler(); } // empty file