Skip to content

Commit 507ffc8

Browse files
[FrameworkBundle] Deprecate making cache.app adapter taggable
1 parent b7e0258 commit 507ffc8

File tree

8 files changed

+64
-1
lines changed

8 files changed

+64
-1
lines changed

UPGRADE-7.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Cache
1212
-----
1313

1414
* `igbinary_serialize()` is not used by default when the igbinary extension is installed
15+
* Deprecate making `cache.app` adapter taggable, use `cache.app.taggable` adapter instead
1516

1617
Form
1718
----

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
* Make the `config/` directory optional in `MicroKernelTrait`, add support for service arguments in the
1010
invokable Kernel class, and register `FrameworkBundle` by default when the `bundles.php` file is missing
1111
* [BC BREAK] The `secrets:decrypt-to-local` command terminates with a non-zero exit code when a secret could not be read
12+
* Deprecate making `cache.app` adapter taggable, use `cache.app.taggable` adapter instead
1213

1314
7.1
1415
---

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,6 +2392,10 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
23922392
$container->setAlias('.'.$name.'.inner', $name);
23932393
$definition->addTag('cache.taggable', ['pool' => $name]);
23942394
} elseif ($pool['tags']) {
2395+
if (\in_array('cache.app', $pool['adapters'], true)) {
2396+
trigger_deprecation('symfony/framework-bundle', '7.2', 'Using the "tags" option with the the default "cache.app" adapter is deprecated. Either use the "cache.app.taggable" adapter or give another tag aware adapter explicitly. The "cache.app.taggable" adapter will be use by default when the "tags" option is used in Symfony 8.0.');
2397+
}
2398+
23952399
if (true !== $pool['tags'] && ($config['pools'][$pool['tags']]['tags'] ?? false)) {
23962400
$pool['tags'] = '.'.$pool['tags'].'.inner';
23972401
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', [
4+
'annotations' => false,
5+
'http_method_override' => false,
6+
'handle_all_throwables' => true,
7+
'php_errors' => ['log' => true],
8+
'cache' => [
9+
'pools' => [
10+
'app.tagaware' => [
11+
'adapter' => 'cache.app',
12+
'tags' => true,
13+
],
14+
],
15+
],
16+
]);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 http-method-override="false" handle-all-throwables="true">
9+
<framework:annotations enabled="false" />
10+
<framework:php-errors log="true" />
11+
<framework:cache>
12+
<framework:pool name="app.cache" adapter="cache.app" tags="true" />
13+
</framework:cache>
14+
</framework:config>
15+
</container>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
framework:
2+
annotations: false
3+
http_method_override: false
4+
handle_all_throwables: true
5+
php_errors:
6+
log: true
7+
cache:
8+
pools:
9+
app.tagaware:
10+
adapter: cache.app
11+
tags: true

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Psr\Cache\CacheItemPoolInterface;
1515
use Psr\Log\LoggerAwareInterface;
16+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1617
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
1718
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
1819
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage;
@@ -93,6 +94,8 @@
9394

9495
abstract class FrameworkExtensionTestCase extends TestCase
9596
{
97+
use ExpectDeprecationTrait;
98+
9699
private static array $containerCache = [];
97100

98101
abstract protected function loadFromFile(ContainerBuilder $container, $file);
@@ -1833,6 +1836,16 @@ public function testCacheTaggableTagAppliedToPools()
18331836
}
18341837
}
18351838

1839+
/**
1840+
* @group legacy
1841+
*/
1842+
public function testTaggableCacheAppIsDeprecated()
1843+
{
1844+
$this->expectDeprecation('Since symfony/framework-bundle 7.2: Using the "tags" option with the the default "cache.app" adapter is deprecated. Either use the "cache.app.taggable" adapter or give another tag aware adapter explicitly. The "cache.app.taggable" adapter will be use by default when the "tags" option is used in Symfony 8.0.');
1845+
1846+
$this->createContainerFromFile('cache_cacheapp_tagaware');
1847+
}
1848+
18361849
/**
18371850
* @dataProvider appRedisTagAwareConfigProvider
18381851
*/

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ framework:
2020
cache.pool3:
2121
clearer: ~
2222
cache.pool4:
23-
tags: true
23+
adapter: cache.app.taggable
2424
public: true
2525
cache.pool5:
26+
adapter: cache.app.taggable
2627
tags: cache.pool2
2728
public: true
2829
cache.pool6:
30+
adapter: cache.app.taggable
2931
tags: cache.pool4
3032
public: true
3133
cache.pool7:

0 commit comments

Comments
 (0)