8000 Merge branch '5.4' into 6.0 · symfony/symfony@220e598 · GitHub
[go: up one dir, main page]

Skip to content

Commit 220e598

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [Cache] Add CouchbaseCollectionAdapter compatibility with sdk 3.0.0 [Cache] Deprecate support for Doctrine Cache
2 parents fac9055 + db76265 commit 220e598

19 files changed

+374
-17
lines changed

.github/workflows/psalm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
uses: shivammathur/setup-php@v2
1818
with:
1919
php-version: '8.0'
20-
extensions: "json,memcached,mongodb,redis,xsl,ldap,dom"
20+
extensions: "json,couchbase,memcached,mongodb,redis,xsl,ldap,dom"
2121
ini-values: "memory_limit=-1"
2222
coverage: none
2323

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
@@ -28,6 +28,7 @@ CHANGELOG
2828
* Deprecate the public `profiler` service to private
2929
* Deprecate `get()`, `has()`, `getDoctrine()`, and `dispatchMessage()` in `AbstractController`, use method/constructor injection instead
3030
* Add `MicroKernelTrait::getBundlesPath` method to get bundles config path
31+
* Deprecate the `cache.adapter.doctrine` service
3132

3233
5.3
3334
---

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
@@ -1481,7 +1481,6 @@ public function testCachePoolServices()
14811481
$container->compile();
14821482

14831483
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foo', 'cache.adapter.apcu', 30);
1484-
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.bar', 'cache.adapter.doctrine', 5);
14851484
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.baz', 'cache.adapter.filesystem', 7);
14861485
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.foobar', 'cache.adapter.psr6', 10);
14871486
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.def', 'cache.app', 'PT11S');
@@ -1523,6 +1522,23 @@ public function testCachePoolServices()
15231522
}
15241523
}
15251524

1525+
/**
1526+
* @group legacy
1527+
*/
1528+
public function testDoctrineCache()
1529+
{
1530+
if (!class_exists(DoctrineAdapter::class)) {
1531+
self::markTestSkipped('This test requires symfony/cache 5.4 or lower.');
1532+
}
1533+
1534+
$container = $this->createContainerFromFile('doctrine_cache', [], true, false);
1535+
$container->setParameter('cache.prefix.seed', 'test');
1536+
$container->addCompilerPass(new CachePoolPass());
1537+
$container->compile();
1538+
1539+
$this->assertCachePoolServiceDefinitionIsCreated($container, 'cache.bar', 'cache.adapter.doctrine', 5);
1540+
}
1541+
15261542
public function testRedisTagAwareAdapter()
15271543
{
15281544
$container = $this->createContainerFromFile('cache', [], true);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ public static function createConnection(string $dsn, a 7C5B rray $options = [])
131131
return MemcachedAdapter::createConnection($dsn, $options);
132132
}
133133
if (0 === strpos($dsn, 'couchbase:')) {
134-
return CouchbaseBucketAdapter::createConnection($dsn, $options);
134+
if (CouchbaseBucketAdapter::isSupported()) {
135+
return CouchbaseBucketAdapter::createConnection($dsn, $options);
136+
}
137+
138+
return CouchbaseCollectionAdapter::createConnection($dsn, $options);
135139
}
136140

137141
throw new InvalidArgumentException(sprintf('Unsupported DSN: "%s".', $dsn));

0 commit comments

Comments
 (0)
0