diff --git a/Resources/doc/features/tagging.rst b/Resources/doc/features/tagging.rst index d0f0617e..d4b89762 100644 --- a/Resources/doc/features/tagging.rst +++ b/Resources/doc/features/tagging.rst @@ -74,11 +74,6 @@ To add tags to responses, use the ``ResponseTagger::addTags`` method:: } } -.. versionadded:: 2.3.2 - Autowiring support has been added in version 2.3.2. In older versions of - the bundle, you need to inject the service - ``fos_http_cache.http.symfony_response_tagger`` into your controller. - To invalidate tags, use the ``CacheManager::invalidateTags($tags)`` method:: use FOS\HttpCacheBundle\CacheManager; @@ -100,11 +95,6 @@ To invalidate tags, use the ``CacheManager::invalidateTags($tags)`` method:: } } -.. versionadded:: 2.3.2 - Autowiring support has been added in version 2.3.2. In older versions of - the bundle, you need to inject the service ``fos_http_cache.cache_manager`` - in your controller. - Tagging from Twig Templates ~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/Resources/doc/overview.rst b/Resources/doc/overview.rst index cc0a5b39..bfeafca5 100644 --- a/Resources/doc/overview.rst +++ b/Resources/doc/overview.rst @@ -18,23 +18,6 @@ To install the bundle together with Symfony HttpClient, run: If you want to use something else than Symfony HttpClient, see Packagist for a list of available `client implementations`_. -If you use an old version of Symfony, you -must manually register the bundle to your application: - -.. code-block:: php - - `. .. _requirements: diff --git a/Resources/doc/reference/cache-manager.rst b/Resources/doc/reference/cache-manager.rst index ba0fb333..61506da5 100644 --- a/Resources/doc/reference/cache-manager.rst +++ b/Resources/doc/reference/cache-manager.rst @@ -18,11 +18,6 @@ By *refreshing* a piece of content, a fresh copy will be fetched right away. The cache manager is available in the Symfony DI container using autowiring with the ``FOS\HttpCacheBundle\CacheManager`` class. -.. versionadded:: 2.3.2 - Autowiring support has been added in version 2.3.2. In older versions of - the bundle, you need to explicitly use the service name - ``fos_http_cache.cache_manager``. - .. _cache manager invalidation: ``invalidatePath()`` diff --git a/Resources/doc/reference/configuration/headers.rst b/Resources/doc/reference/configuration/headers.rst index 3d830b26..cb07df52 100644 --- a/Resources/doc/reference/configuration/headers.rst +++ b/Resources/doc/reference/configuration/headers.rst @@ -136,8 +136,7 @@ way to determine if it was manually set. If the full header is only You can prevent the cache control on specific controller actions by calling ``FOS\HttpCacheBundle\EventListener\CacheControlListener::setSkip()``. When skip is set to ``true``, no cache rules are applied. This service can be -autowired - in older versions of the bundle, use the service -``fos_http_cache.event_listener.cache_control``. +autowired. ``cache_control`` """"""""""""""""" @@ -220,9 +219,7 @@ directives are flags that are included when set to true: This enables a simplistic ETag calculated as md5 hash of the response body: -.. versionadded:: 2.2 - - You can set up ETag to be strong or weak by setting the option to "strong" or "weak" respectively. +You can set up ETag to be strong or weak by setting the option to "strong" or "weak" respectively. .. code-block:: yaml diff --git a/Resources/doc/reference/configuration/proxy-client.rst b/Resources/doc/reference/configuration/proxy-client.rst index 07d73124..2b40f2d5 100644 --- a/Resources/doc/reference/configuration/proxy-client.rst +++ b/Resources/doc/reference/configuration/proxy-client.rst @@ -213,13 +213,11 @@ refer to the :ref:`FOSHttpCache documentation for Symfony `. +You can omit the whole ``http`` configuration and use ``use_kernel_dispatcher: true`` +instead. This will call the kernel directly instead of executing a real +HTTP request. Note that your kernel and bootstrapping need to be adjusted +to support this feature. The setup is explained in the +:ref:`Symfony HttpCache chapter `. ``tags_method`` """"""""""""""" diff --git a/Resources/doc/reference/configuration/user-context.rst b/Resources/doc/reference/configuration/user-context.rst index 39ff36d8..1bbcaac6 100644 --- a/Resources/doc/reference/configuration/user-context.rst +++ b/Resources/doc/reference/configuration/user-context.rst @@ -148,10 +148,6 @@ For the handler to work: * Symfony’s default behavior of regenerating the session id when users log in and out must be enabled (``invalidate_session``). -.. warning:: - The cache invalidation on logout only works correctly with FOSHttpCacheBundle 2.2 and later. - It was broken in older versions of the bundle. - .. tip:: The logout handler is active on all firewalls. If your application has multiple firewalls with different user context, you need to create your own @@ -232,12 +228,11 @@ Custom providers need to: * implement the ``FOS\HttpCache\UserContext\ContextProvider`` interface * be tagged with ``fos_http_cache.user_context_provider``. -.. versionadded:: 2.4.0 - Since version 2.4.0, context providers are autoconfigured. With - autoconfigure enabled in Symfony 3.3 and newer, your custom providers - are tagged automatically, with a default priority of 0. For older - versions, or if autoconfigure is disabled, or to override the - priority, check out the rest of this section. +.. tip:: + Context providers are autoconfigured. With autoconfigure enabled in + Symfony, your custom providers are tagged automatically, with a default + priority of 0. If you disabled autoconfigure, or to override the priority, + check out the rest of this section. If you need context providers to run in a specific order, you can specify the optional ``priority`` parameter for the tag. The higher the priority, the diff --git a/tests/Functional/EventListener/SwitchUserListenerTest.php b/tests/Functional/EventListener/SwitchUserListenerTest.php index d8131da7..3bbff0e9 100644 --- a/tests/Functional/EventListener/SwitchUserListenerTest.php +++ b/tests/Functional/EventListener/SwitchUserListenerTest.php @@ -16,9 +16,7 @@ use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -use Symfony\Component\BrowserKit\Cookie; use Symfony\Component\HttpKernel\KernelInterface; -use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\User\InMemoryUser; use Symfony\Component\Security\Core\User\UserInterface; @@ -72,22 +70,7 @@ public function testInvalidateContext() public function loginAsAdmin(KernelBrowser $client) { - if (method_exists($client, 'loginUser')) { - $client->loginUser($this->createAdminUser(), self::FIREWALL_NAME); - - return; - } - - $session = $client->getContainer()->get('session'); - - $user = $this->createAdminUser(); - - $token = new UsernamePasswordToken($user, self::FIREWALL_NAME, $user->getRoles()); - $session->set('_security_'.self::FIREWALL_NAME, serialize($token)); - $session->save(); - - $cookie = new Cookie($session->getName(), $session->getId()); - $client->getCookieJar()->set($cookie); + $client->loginUser($this->createAdminUser(), self::FIREWALL_NAME); } private function createAdminUser(): UserInterface diff --git a/tests/Functional/Fixtures/app/AppKernel.php b/tests/Functional/Fixtures/app/AppKernel.php index f122661e..e70a6f22 100644 --- a/tests/Functional/Fixtures/app/AppKernel.php +++ b/tests/Functional/Fixtures/app/AppKernel.php @@ -61,11 +61,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void } else { $loader->load(__DIR__.'/config/config.yml'); } - if (\version_compare(Kernel::VERSION, '6.0', '>=')) { - $loader->load(__DIR__.'/config/config_6.yml'); - } else { - $loader->load(__DIR__.'/config/config_4.yml'); - } + $loader->load(__DIR__.'/config/config_security.yml'); $loader->load(__DIR__.'/config/services.yml'); diff --git a/tests/Functional/Fixtures/app/config/config.yml b/tests/Functional/Fixtures/app/config/config.yml index 1438c932..653e2f0b 100644 --- a/tests/Functional/Fixtures/app/config/config.yml +++ b/tests/Functional/Fixtures/app/config/config.yml @@ -3,6 +3,8 @@ framework: router: resource: "%kernel.project_dir%/tests/Functional/Fixtures/app/config/routing.yml" test: ~ + session: + storage_factory_id: session.storage.factory.mock_file fos_http_cache: cacheable: diff --git a/tests/Functional/Fixtures/app/config/config_4.yml b/tests/Functional/Fixtures/app/config/config_4.yml deleted file mode 100644 index 685407b0..00000000 --- a/tests/Functional/Fixtures/app/config/config_4.yml +++ /dev/null @@ -1,21 +0,0 @@ -framework: - session: - storage_id: session.test_storage - -security: - providers: - in_memory: - memory: - users: - user: { password: user, roles: 'ROLE_USER' } - admin: { password: admin, roles: [ 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH' ] } - firewalls: - secured_area: - pattern: ^/secured_area - anonymous: - http_basic: true - switch_user: true - logout: - path: /secured_area/logout - encoders: - Symfony\Component\Security\Core\User\User: plaintext diff --git a/tests/Functional/Fixtures/app/config/config_6.yml b/tests/Functional/Fixtures/app/config/config_security.yml similarity index 79% rename from tests/Functional/Fixtures/app/config/config_6.yml rename to tests/Functional/Fixtures/app/config/config_security.yml index 12fbbc6c..e18fac42 100644 --- a/tests/Functional/Fixtures/app/config/config_6.yml +++ b/tests/Functional/Fixtures/app/config/config_security.yml @@ -1,9 +1,3 @@ -# configuration to make symfony 6 work as expected - -framework: - session: - storage_factory_id: session.storage.factory.mock_file - security: providers: in_memory: diff --git a/tests/Functional/Fixtures/app/config/security-legacy.yml b/tests/Functional/Fixtures/app/config/security-legacy.yml deleted file mode 100644 index 7a3bef4c..00000000 --- a/tests/Functional/Fixtures/app/config/security-legacy.yml +++ /dev/null @@ -1,17 +0,0 @@ -security: - providers: - in_memory: - memory: - users: - user: { password: user, roles: 'ROLE_USER' } - admin: { password: admin, roles: ['ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'] } - encoders: - Symfony\Component\Security\Core\User\User: plaintext - firewalls: - secured_area: - pattern: ^/secured_area - anonymous: - http_basic: true - switch_user: true - logout: - path: /secured_area/logout diff --git a/tests/Unit/EventListener/UserContextListenerTest.php b/tests/Unit/EventListener/UserContextListenerTest.php index 97532d29..9c268959 100644 --- a/tests/Unit/EventListener/UserContextListenerTest.php +++ b/tests/Unit/EventListener/UserContextListenerTest.php @@ -23,7 +23,6 @@ use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\EventListener\AbstractSessionListener; use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Kernel; class UserContextListenerTest extends TestCase { @@ -238,10 +237,6 @@ public function testOnKernelResponse() public function testOnKernelResponseSetsNoAutoCacheHeader() { - if (\version_compare('4.1', Kernel::VERSION, '>')) { - $this->markTestSkipped('Test only relevant for Symfony 4.1 and up'); - } - $request = new Request(); $request->setMethod('HEAD'); $request->headers->set('X-User-Context-Hash', 'hash'); @@ -263,10 +258,6 @@ public function testOnKernelResponseSetsNoAutoCacheHeader() public function testOnKernelResponseDoesNotSetNoAutoCacheHeaderWhenNoSessionListener() { - if (\version_compare('4.1', Kernel::VERSION, '>')) { - $this->markTestSkipped('Test only relevant for Symfony 4.1 and up'); - } - $request = new Request(); $request->setMethod('HEAD'); $request->headers->set('X-User-Context-Hash', 'hash'); @@ -292,10 +283,6 @@ public function testOnKernelResponseDoesNotSetNoAutoCacheHeaderWhenNoSessionList public function testOnKernelResponseSetsNoAutoCacheHeaderWhenCustomHeader() { - if (\version_compare('4.1', Kernel::VERSION, '>')) { - $this->markTestSkipped('Test only relevant for Symfony 4.1 and up'); - } - $request = new Request(); $request->setMethod('HEAD'); $request->headers->set('X-User-Context-Hash', 'hash'); @@ -316,10 +303,6 @@ public function testOnKernelResponseSetsNoAutoCacheHeaderWhenCustomHeader() public function testOnKernelResponseSetsNoAutoCacheHeaderWhenCustomHeaderAndNoAddVaryOnHash() { - if (\version_compare('4.1', Kernel::VERSION, '>')) { - $this->markTestSkipped('Test only relevant for Symfony 4.1 and up'); - } - $request = new Request(); $request->setMethod('HEAD'); $request->headers->set('X-User-Context-Hash', 'hash'); @@ -345,10 +328,6 @@ public function testOnKernelResponseSetsNoAutoCacheHeaderWhenCustomHeaderAndNoAd public function testOnKernelResponseDoesNotSetNoAutoCacheHeaderWhenNoCustomHeaderAndNoAddVaryOnHash() { - if (\version_compare('4.1', Kernel::VERSION, '>')) { - $this->markTestSkipped('Test only relevant for Symfony 4.1 and up'); - } - $request = new Request(); $request->setMethod('HEAD'); $request->headers->set('X-User-Context-Hash', 'hash');