Skip to content

Commit

Permalink
Merge pull request #625 from FriendsOfSymfony/cleanup-legacy-support
Browse files Browse the repository at this point in the history
remove remaining legacy code and doc
  • Loading branch information
dbu committed May 3, 2024
2 parents f343e22 + 58c9ef4 commit 8ab0ed8
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 142 deletions.
10 changes: 0 additions & 10 deletions Resources/doc/features/tagging.rst
Expand Up @@ -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;
Expand All @@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
17 changes: 0 additions & 17 deletions Resources/doc/overview.rst
Expand Up @@ -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
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new FOS\HttpCacheBundle\FOSHttpCacheBundle(),
// ...
);
}
For most features, you also need to :ref:`configure a caching proxy <foshttpcache:proxy-configuration>`.

.. _requirements:
Expand Down
5 changes: 0 additions & 5 deletions Resources/doc/reference/cache-manager.rst
Expand Up @@ -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()``
Expand Down
7 changes: 2 additions & 5 deletions Resources/doc/reference/configuration/headers.rst
Expand Up @@ -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``
"""""""""""""""""
Expand Down Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions Resources/doc/reference/configuration/proxy-client.rst
Expand Up @@ -213,13 +213,11 @@ refer to the :ref:`FOSHttpCache documentation for Symfony <foshttpcache:symfony
For ``servers``, ``base_url``, ``tags_header`` and ``header_length``, see above.

.. versionadded:: 2.3

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 <symfony_http_cache_kernel_dispatcher>`.
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 <symfony_http_cache_kernel_dispatcher>`.

``tags_method``
"""""""""""""""
Expand Down
15 changes: 5 additions & 10 deletions Resources/doc/reference/configuration/user-context.rst
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 1 addition & 18 deletions tests/Functional/EventListener/SwitchUserListenerTest.php
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions tests/Functional/Fixtures/app/AppKernel.php
Expand Up @@ -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');

Expand Down
2 changes: 2 additions & 0 deletions tests/Functional/Fixtures/app/config/config.yml
Expand Up @@ -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:
Expand Down
21 changes: 0 additions & 21 deletions tests/Functional/Fixtures/app/config/config_4.yml

This file was deleted.

@@ -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:
Expand Down
17 changes: 0 additions & 17 deletions tests/Functional/Fixtures/app/config/security-legacy.yml

This file was deleted.

21 changes: 0 additions & 21 deletions tests/Unit/EventListener/UserContextListenerTest.php
Expand Up @@ -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
{
Expand Down Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand Down

0 comments on commit 8ab0ed8

Please sign in to comment.