10000 [Cache] Deprecate support for Doctrine Cache · symfony/symfony@595c786 · GitHub
[go: up one dir, main page]

Skip to content

Commit 595c786

Browse files
committed
[Cache] Deprecate support for Doctrine Cache
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parent 98ed693 commit 595c786

File tree

14 files changed

+69
-15
lines changed

14 files changed

+69
-15
lines changed

UPGRADE-5.4.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ UPGRADE FROM 5.3 to 5.4
44
Cache
55
-----
66

7-
* Deprecate `DoctrineProvider` because this class has been added to the `doctrine/cache` package
7+
* Deprecate `DoctrineProvider` and `DoctrineAdapter` because these classes have been added to the `doctrine/cache` package
88

99
Console
1010
-------
@@ -28,6 +28,7 @@ FrameworkBundle
2828
* Deprecate the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
2929
* Deprecate the public `profiler` service to private
3030
* Deprecate `get()`, `has()`, `getDoctrine()`, and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead
31+
* Deprecate the `cache.adapter.doctrine` service: The Doctrine Cache library is deprecated. Either switch to Symfony Cache or use the PSR-6 adapters provided by Doctrine Cache.
3132

3233
HttpKernel
3334
----------

UPGRADE-6.0.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ DoctrineBridge
1414
Cache
1515
-----
1616

17-
* Remove `DoctrineProvider` because it has been added to the `doctrine/cache` package
17+
* Remove `DoctrineProvider` and `DoctrineAdapter` because these classes have been added to the `doctrine/cache` package
1818

1919
Config
2020
------
@@ -104,6 +104,7 @@ FrameworkBundle
104104
* Remove option `--output-format` of the `translation:update` command, use e.g. `--output-format=xlf20` instead
105105
* Remove the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
106106
* Remove `get()`, `has()`, `getDoctrine()`, and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead
107+
* Deprecate the `cache.adapter.doctrine` service: The Doctrine Cache library is deprecated. Either switch to Symfony Cache or use the PSR-6 adapters provided by Doctrine Cache.
107108

108109
HttpFoundation
109110
--------------

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CHANGELOG
99
* Deprecate the public `profiler` service to private
1010
* Deprecate `get()`, `has()`, `getDoctrine()`, and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead
1111
* Add `MicroKernelTrait::getBundlesPath` method to get bundles config path
12+
* Deprecate the `cache.adapter.doctrine` service
1213

1314
5.3
1415
---

src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,10 @@
9393
->call('setLogger', [service('logger')->ignoreOnInvalid()])
9494
->tag('cache.pool', ['clearer' => 'cache.default_clearer', 'reset' => 'reset'])
9595
->tag('monolog.logger', ['channel' => 'cache'])
96+
;
9697

97-
->set('cache.adapter.doctrine', DoctrineAdapter::class)
98+
if (class_exists(DoctrineAdapter::class)) {
99+
$container->services()->set('cache.adapter.doctrine', DoctrineAdapter::class)
98100
->abstract()
99101
->args([
100102
abstract_arg('Doctrine provider service'),
@@ -108,7 +110,11 @@
108110
'reset' => 'reset',
109111
])
110112
->tag('monolog.logger', ['channel' => 'cache'])
113+
->deprecate('symfony/framework-bundle', '5.4', 'The abstract service "%service_id%" is deprecated.')
114+
;
115+
}
111116

117+
$container->services()
112118
->set('cache.adapter.filesystem', FilesystemAdapter::class)
113119
->abstract()
114120
->args([

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
'adapter' => 'cache.adapter.apcu',
88
'default_lifetime' => 30,
99
],
10-
'cache.bar' => [
11-
'adapter' => 'cache.adapter.doctrine',
12-
'default_lifetime' => 5,
13-
'provider' => 'app.doctrine_cache_provider',
14-
],
1510
'cache.baz' => [
1611
'adapter' => 'cache.adapter.filesystem',
1712
'default_lifetime' => 7,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', [
4+
'cache' => [
5+
'pools' => [
6+
'cache.bar' => [
7+
'adapter' => 'cache.adapter.doctrine',
8+
'default_lifetime' => 5,
9+
'provider' => 'app.doctrine_cache_provider',
10+
],
11+
],
12+
],
13+
]);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<framework:config>
99
<framework:cache>
1010
<framework:pool name="cache.foo" adapter="cache.adapter.apcu" default-lifetime="30" />
11-
<framework:pool name="cache.bar" adapter="cache.adapter.doctrine" default-lifetime="5" provider="app.doctrine_cache_provider" />
1211
<framework:pool name="cache.baz" adapter="cache.adapter.filesystem" default-lifetime="7" />
1312
<framework:pool name="cache.foobar" adapter="cache.adapter.psr6" default-lifetime="10" provider="app.cache_pool" />
1413
<framework:pool name="cache.def" default-lifetime="PT11S" />
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:cache>
10+
<framework:pool name="cache.bar" adapter="cache.adapter.doctrine" default-lifetime="5" provider="app.doctrine_cache_provider" />
11+
</framework:cache>
12+
</framework:config>
13+
</container>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ framework:
44
cache.foo:
55
adapter: cache.adapter.apcu
66
default_lifetime: 30
7-
cache.bar:
8-
adapter: cache.adapter.doctrine
9-
default_lifetime: 5
10-
provider: app.doctrine_cache_provider
117
cache.baz:
128
adapter: cache.adapter.filesystem
139
default_lifetime: 7
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
framework:
2+
cache:
3+
pools:
4+
cache.bar:
5+
adapter: cache.adapter.doctrine
6+
default_lifetime: 5
7+
provider: app.doctrine_cache_provider

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,6 @@ public function testCachePoolServices()
15191519
$container->compile();
15201520

15211521
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foo', 'cache.adapter.apcu', 30);
1522-
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.bar', 'cache.adapter.doctrine', 5);
15231522
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.baz', 'cache.adapter.filesystem', 7);
15241523
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foobar', 'cache.adapter.psr6', 10);
15251524
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.def', 'cache.app', 'PT11S');
@@ -1561,6 +1560,23 @@ public function testCachePoolServices()
15611560
}
15621561
}
15631562

1563+
/**
1564+
* @group legacy
1565+
*/
1566+
public function testDoctrineCache()
1567+
{
1568+
if (!class_exists(DoctrineAdapter::class)) {
1569+
self::markTestSkipped('This test requires symfony/cache 5.4 or lower.');
1570+
}
1571+
1572+
$container = $this->createContainerFromFile('doctrine_cache', [], true, false);
1573+
$container->setParameter('cache.prefix.seed', 'test');
1574+
$container->addCompilerPass(new CachePoolPass());
1575+
$container->compile();
1576+
1577+
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.bar', 'cache.adapter.doctrine', 5);
1578+
}
1579+
15641580
public function testRedisTagAwareAdapter()
15651581
{
15661582
$container = $this->createContainerFromFile('cache', [], true);

src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,21 @@
1212
namespace Symfony\Component\Cache\Adapter;
1313

1414
use Doctrine\Common\Cache\CacheProvider;
15+
use Doctrine\Common\Cache\Psr6\CacheAdapter;
1516

1617
/**
1718
* @author Nicolas Grekas <p@tchwork.com>
19+
*
20+
* @deprecated Since Symfony 5.4, use Doctrine\Common\Cache\Psr6\CacheAdapter instead
1821
*/
1922
class DoctrineAdapter extends AbstractAdapter
2023
{
2124
private $provider;
2225

2326
public function __construct(CacheProvider $provider, string $namespace = '', int $defaultLifetime = 0)
2427
{
28+
trigger_deprecation('symfony/cache', '5.4', '"%s" is deprecated, use "%s" instead.', __CLASS__, CacheAdapter::class);
29+
2530
parent::__construct('', $defaultLifetime);
2631
$this->provider = $provider;
2732
$provider->setNamespace($namespace);

src/Symfony/Component/Cache/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CHANGELOG
55
---
66

77
* Make `LockRegistry` use semaphores when possible
8-
* Deprecate `DoctrineProvider` because this class has been added to the `doctrine/cache` package
8+
* Deprecate `DoctrineProvider` and `DoctrineAdapter` because these classes have been added to the `doctrine/cache` package
99

1010
5.3
1111
---

src/Symfony/Component/Cache/Tests/Adapter/DoctrineAdapterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Cache\Tests\Fixtures\ArrayCache;
1717

1818
/**
19+
* @group legacy
1920
* @group time-sensitive
2021
*/
2122
class DoctrineAdapterTest extends AdapterTestCase

0 commit comments

Comments
 (0)
0