Skip to content

Commit baa5768

Browse files
committed
feature #42965 [Cache] Deprecate support for Doctrine Cache (derrabus)
This PR was merged into the 5.4 branch. Discussion ---------- [Cache] Deprecate support for Doctrine Cache | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | yes | Deprecations? | yes | Tickets | N/A | License | MIT | Doc PR | N/A The Doctrine Cache library is deprecated. I don't think we need to keep integration logic for Doctrine Cache in the 6.0 branch. Apps still relying on Doctrine Cache implementations can either: * Find a suitable replacement among Symfony Cache's adapters. * Wire their custom Doctrine Cache implementation into Doctrine's own PSR-6 adapter. Commits ------- 595c786123 [Cache] Deprecate support for Doctrine Cache
2 parents 71067b8 + 1144464 commit baa5768

File tree

9 files changed

+58
-12
lines changed

9 files changed

+58
-12
lines changed

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
---

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([

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+
]);

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>

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

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);

0 commit comments

Comments
 (0)