From 8504e5e33d7b620f6d2417ef86a226a4b41d5b46 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Thu, 28 Mar 2024 10:42:41 +0100 Subject: [PATCH] remove deprecated code --- .github/workflows/php.yml | 4 +- CHANGELOG.md | 3 ++ .../FOSHttpCacheExtension.php | 7 --- src/Resources/config/user_context_legacy.xml | 13 ----- .../config/user_context_legacy_sf6.xml | 13 ----- .../ContextInvalidationLogoutHandler.php | 51 ------------------- src/UserContext/AnonymousRequestMatcher.php | 40 --------------- .../FOSHttpCacheExtensionTest.php | 6 +-- 8 files changed, 8 insertions(+), 129 deletions(-) delete mode 100644 src/Resources/config/user_context_legacy.xml delete mode 100644 src/Resources/config/user_context_legacy_sf6.xml delete mode 100644 src/Security/Http/Logout/ContextInvalidationLogoutHandler.php delete mode 100644 src/UserContext/AnonymousRequestMatcher.php diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 445948b0..8629f3de 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -21,12 +21,12 @@ jobs: dependencies: 'jean-beru/fos-http-cache-cloudfront' - php-version: '8.1' symfony-version: '6.4' + - php-version: '8.2' + symfony-version: '6.4' - php-version: '8.2' symfony-version: '7.*' - php-version: '8.3' symfony-version: '7.*' - - php-version: '8.2' - symfony-version: '6.4' # Minimum supported dependencies with the oldest PHP version - php-version: '8.1' composer-flag: '--prefer-stable --prefer-lowest' diff --git a/CHANGELOG.md b/CHANGELOG.md index 2848eba8..ca700180 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ Changelog Remove all configuration you have at `fos_http_cache.tags.annotations` * Make `fastly` and `cloudflare` clients lazy loaded to support Symfony secrets that are only available at runtime, but not yet when the container is built. +* Removed deprecated `FOS\HttpCacheBundle\UserContext\AnonymousRequestMatcher`, use the + `FOS\HttpCache\UserContext\AnonymousRequestMatcher` class. +* Removed deprecated `ContextInvalidationLogoutHandler`, use `ContextInvalidationSessionLogoutHandle` instead. 2.x === diff --git a/src/DependencyInjection/FOSHttpCacheExtension.php b/src/DependencyInjection/FOSHttpCacheExtension.php index 447c9119..ec734429 100644 --- a/src/DependencyInjection/FOSHttpCacheExtension.php +++ b/src/DependencyInjection/FOSHttpCacheExtension.php @@ -28,7 +28,6 @@ use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class FOSHttpCacheExtension extends Extension @@ -281,12 +280,6 @@ private function loadUserContext(ContainerBuilder $container, XmlFileLoader $loa } $loader->load('user_context.xml'); - // TODO: Remove this service file when going to version 3 of the bundle - if (Kernel::MAJOR_VERSION >= 6) { - $loader->load('user_context_legacy_sf6.xml'); - } else { - $loader->load('user_context_legacy.xml'); - } $container->getDefinition('fos_http_cache.user_context.request_matcher') ->replaceArgument(0, $config['match']['accept']) diff --git a/src/Resources/config/user_context_legacy.xml b/src/Resources/config/user_context_legacy.xml deleted file mode 100644 index ae060183..00000000 --- a/src/Resources/config/user_context_legacy.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - The "%service_id%" service is deprecated since 2.2 and will be removed in 3.0. - - - diff --git a/src/Resources/config/user_context_legacy_sf6.xml b/src/Resources/config/user_context_legacy_sf6.xml deleted file mode 100644 index cf23e18f..00000000 --- a/src/Resources/config/user_context_legacy_sf6.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - The "%service_id%" service is deprecated since 2.2 and will be removed in 3.0. - - - diff --git a/src/Security/Http/Logout/ContextInvalidationLogoutHandler.php b/src/Security/Http/Logout/ContextInvalidationLogoutHandler.php deleted file mode 100644 index 5e99c014..00000000 --- a/src/Security/Http/Logout/ContextInvalidationLogoutHandler.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\HttpCacheBundle\Security\Http\Logout; - -use FOS\HttpCacheBundle\UserContextInvalidator; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Http\Event\LogoutEvent; -use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface; - -/** - * @deprecated use ContextInvalidationSessionLogoutHandler in this same namespace as a replacement - * - * This handler is deprecated because it never did what it was supposed to do. The session is already invalidated by the SessionLogoutHandler - * which is always the first logout handler executed - */ -final class ContextInvalidationLogoutHandler implements LogoutHandlerInterface -{ - private $invalidator; - - public function __construct(UserContextInvalidator $invalidator) - { - $this->invalidator = $invalidator; - } - - /** - * {@inheritdoc} - */ - public function logout(Request $request, Response $response, TokenInterface $token) - { - @trigger_error('Using the ContextInvalidationLogoutHandler is deprecated', E_USER_DEPRECATED); - - if (class_exists(LogoutEvent::class)) { - // This class no longer works at all with Symfony 5.1, force usage of ContextInvalidationSessionLogoutHandler instead - // See also: https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/pull/545#discussion_r465089219 - throw new \LogicException(__CLASS__.'::'.__METHOD__.' no longer works with Symfony 5.1. Remove fos_http_cache.user_context.logout_handler from your firewall configuration. See the changelog for version 2.2. for more information.'); - } - - $this->invalidator->invalidateContext($request->getSession()->getId()); - } -} diff --git a/src/UserContext/AnonymousRequestMatcher.php b/src/UserContext/AnonymousRequestMatcher.php deleted file mode 100644 index 2241c99b..00000000 --- a/src/UserContext/AnonymousRequestMatcher.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace FOS\HttpCacheBundle\UserContext; - -use FOS\HttpCache\UserContext\AnonymousRequestMatcher as BaseAnonymousRequestMatcher; - -/** - * Matches anonymous requests using a list of identification headers. - * - * @deprecated Use AnonymousRequestMatcher of HttpCache library - */ -class AnonymousRequestMatcher extends BaseAnonymousRequestMatcher -{ - public function __construct(array $options = []) - { - @trigger_error( - 'AnonymousRequestMatcher of HttpCacheBundle is deprecated. '. - 'Use AnonymousRequestMatcher of HttpCache library.', - E_USER_DEPRECATED - ); - - if (isset($options['user_identifier_headers'], $options['session_name_prefix'])) { - parent::__construct($options); - } else { - parent::__construct([ - 'user_identifier_headers' => $options, - 'session_name_prefix' => 'PHPSESSID', - ]); - } - } -} diff --git a/tests/Unit/DependencyInjection/FOSHttpCacheExtensionTest.php b/tests/Unit/DependencyInjection/FOSHttpCacheExtensionTest.php index 553a868b..49b8fc5b 100644 --- a/tests/Unit/DependencyInjection/FOSHttpCacheExtensionTest.php +++ b/tests/Unit/DependencyInjection/FOSHttpCacheExtensionTest.php @@ -285,7 +285,7 @@ public function testEmptyConfig() $container = $this->createContainer(); $this->extension->load([$config], $container); - $this->assertFalse($container->has('fos_http_cache.user_context.logout_handler')); + $this->assertFalse($container->has('fos_http_cache.user_context.session_logout_handler')); } public function testConfigTagNotSupported() @@ -580,7 +580,7 @@ public function testConfigUserContext() $this->assertTrue($container->has('fos_http_cache.user_context.hash_generator')); $this->assertTrue($container->has('fos_http_cache.user_context.request_matcher')); $this->assertTrue($container->has('fos_http_cache.user_context.role_provider')); - $this->assertTrue($container->has('fos_http_cache.user_context.logout_handler')); + $this->assertTrue($container->has('fos_http_cache.user_context.session_logout_handler')); $this->assertEquals(['fos_http_cache.user_context.role_provider' => [[]]], $container->findTaggedServiceIds('fos_http_cache.user_context_provider')); } @@ -610,7 +610,7 @@ public function testConfigWithoutUserContext() $this->assertFalse($container->has('fos_http_cache.user_context.hash_generator')); $this->assertFalse($container->has('fos_http_cache.user_context.request_matcher')); $this->assertFalse($container->has('fos_http_cache.user_context.role_provider')); - $this->assertFalse($container->has('fos_http_cache.user_context.logout_handler')); + $this->assertFalse($container->has('fos_http_cache.user_context.session_logout_handler')); $this->assertFalse($container->has('fos_http_cache.user_context.session_listener')); }