Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Cache] Deprecate support for Doctrine Cache #42965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 3 UPGRADE-5.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ UPGRADE FROM 5.3 to 5.4
Cache
-----

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

Console
-------
Expand All @@ -28,6 +28,7 @@ FrameworkBundle
* Deprecate the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
* Deprecate the public `profiler` service to private
* Deprecate `get()`, `has()`, `getDoctrine()`, and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead
* 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.

HttpKernel
----------
Expand Down
3 changes: 2 additions & 1 deletion 3 UPGRADE-6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DoctrineBridge
Cache
-----

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

Config
------
Expand Down Expand Up @@ -104,6 +104,7 @@ FrameworkBundle
* Remove option `--output-format` of the `translation:update` command, use e.g. `--output-format=xlf20` instead
* Remove the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
* Remove `get()`, `has()`, `getDoctrine()`, and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead
* 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.

HttpFoundation
--------------
Expand Down
1 change: 1 addition & 0 deletions 1 src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CHANGELOG
* Deprecate the public `profiler` service to private
* Deprecate `get()`, `has()`, `getDoctrine()`, and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead
* Add `MicroKernelTrait::getBundlesPath` method to get bundles config path
* Deprecate the `cache.adapter.doctrine` service

5.3
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@
->call('setLogger', [service('logger')->ignoreOnInvalid()])
->tag('cache.pool', ['clearer' => 'cache.default_clearer', 'reset' => 'reset'])
->tag('monolog.logger', ['channel' => 'cache'])
;

->set('cache.adapter.doctrine', DoctrineAdapter::class)
if (class_exists(DoctrineAdapter::class)) {
$container->services()->set('cache.adapter.doctrine', DoctrineAdapter::class)
->abstract()
->args([
abstract_arg('Doctrine provider service'),
Expand All @@ -108,7 +110,11 @@
'reset' => 'reset',
])
->tag('monolog.logger', ['channel' => 'cache'])
->deprecate('symfony/framework-bundle', '5.4', 'The abstract service "%service_id%" is deprecated.')
;
}

$container->services()
->set('cache.adapter.filesystem', FilesystemAdapter::class)
->abstract()
->args([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
'adapter' => 'cache.adapter.apcu',
'default_lifetime' => 30,
],
'cache.bar' => [
'adapter' => 'cache.adapter.doctrine',
'default_lifetime' => 5,
'provider' => 'app.doctrine_cache_provider',
],
'cache.baz' => [
'adapter' => 'cache.adapter.filesystem',
'default_lifetime' => 7,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

$container->loadFromExtension('framework', [
'cache' => [
'pools' => [
'cache.bar' => [
'adapter' => 'cache.adapter.doctrine',
'default_lifetime' => 5,
'provider' => 'app.doctrine_cache_provider',
],
],
],
]);
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<framework:config>
<framework:cache>
<framework:pool name="cache.foo" adapter="cache.adapter.apcu" default-lifetime="30" />
<framework:pool name="cache.bar" adapter="cache.adapter.doctrine" default-lifetime="5" provider="app.doctrine_cache_provider" />
<framework:pool name="cache.baz" adapter="cache.adapter.filesystem" default-lifetime="7" />
<framework:pool name="cache.foobar" adapter="cache.adapter.psr6" default-lifetime="10" provider="app.cache_pool" />
<framework:pool name="cache.def" default-lifetime="PT11S" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:cache>
<framework:pool name="cache.bar" adapter="cache.adapter.doctrine" default-lifetime="5" provider="app.doctrine_cache_provider" />
</framework:cache>
</framework:config>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ framework:
cache.foo:
adapter: cache.adapter.apcu
default_lifetime: 30
cache.bar:
adapter: cache.adapter.doctrine
default_lifetime: 5
provider: app.doctrine_cache_provider
cache.baz:
adapter: cache.adapter.filesystem
default_lifetime: 7
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
framework:
cache:
pools:
cache.bar:
adapter: cache.adapter.doctrine
default_lifetime: 5
provider: app.doctrine_cache_provider
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,6 @@ public function testCachePoolServices()
$container->compile();

$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foo', 'cache.adapter.apcu', 30);
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.bar', 'cache.adapter.doctrine', 5);
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.baz', 'cache.adapter.filesystem', 7);
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foobar', 'cache.adapter.psr6', 10);
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.def', 'cache.app', 'PT11S');
Expand Down Expand Up @@ -1561,6 +1560,23 @@ public function testCachePoolServices()
}
}

/**
* @group legacy
*/
public function testDoctrineCache()
{
if (!class_exists(DoctrineAdapter::class)) {
self::markTestSkipped('This test requires symfony/cache 5.4 or lower.');
}

$container = $this->createContainerFromFile('doctrine_cache', [], true, false);
$container->setParameter('cache.prefix.seed', 'test');
$container->addCompilerPass(new CachePoolPass());
$container->compile();

$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.bar', 'cache.adapter.doctrine', 5);
}

public function testRedisTagAwareAdapter()
{
$container = $this->createContainerFromFile('cache', [], true);
Expand Down
5 changes: 5 additions & 0 deletions 5 src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@
namespace Symfony\Component\Cache\Adapter;

use Doctrine\Common\Cache\CacheProvider;
use Doctrine\Common\Cache\Psr6\CacheAdapter;

/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @deprecated Since Symfony 5.4, use Doctrine\Common\Cache\Psr6\CacheAdapter instead
*/
class DoctrineAdapter extends AbstractAdapter
{
private $provider;

public function __construct(CacheProvider $provider, string $namespace = '', int $defaultLifetime = 0)
{
trigger_deprecation('symfony/cache', '5.4', '"%s" is deprecated, use "%s" instead.', __CLASS__, CacheAdapter::class);

parent::__construct('', $defaultLifetime);
$this->provider = $provider;
$provider->setNamespace($namespace);
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/Cache/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CHANGELOG
---

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

5.3
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\Cache\Tests\Fixtures\ArrayCache;

/**
* @group legacy
* @group time-sensitive
*/
class DoctrineAdapterTest extends AdapterTestCase
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.