8000 [FrameworkBundle] Deprecate making `cache.app` adapter taggable · symfony/symfony@c411932 · GitHub
[go: up one dir, main page]

Skip to content

Commit c411932

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

File tree

7 files changed

+62
-0
lines changed

7 files changed

+62
-0
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 the `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 the `cache.app.taggable` adapter instead
1213

1314
7.1
1415
---

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,6 +2363,11 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
23632363
];
23642364
}
23652365
foreach ($config['pools'] as $name => $pool) {
2366+
if (\in_array('cache.app', $pool['adapters'] ?? [], true) && $pool['tags']) {
2367+
trigger_deprecation('symfony/framework-bundle', '7.2', 'Using the "tags" option with the "cache.app" adapter is deprecated. You should either use the "cache.app.taggable" adapter or give another tag aware adapter explicitly to the "tags" option. Using the "cache.app" adapter with the "tags" option will throw an exception in Symfony 8.0.');
2368+
// throw new InvalidArgumentException('The "tags" option cannot be used with the "cache.app" adapter. You should use the "cache.app.taggable" adapter or give another tag aware adapter explicitly to the "tags" option.');
2369+
}
2370+
23662371
$pool['adapters'] = $pool['adapters'] ?: ['cache.app'];
23672372

23682373
$isRedisTagAware = ['cache.adapter.redis_tag_aware'] === $pool['adapters'];
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.tagaware" 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 "cache.app" adapter is deprecated. You should either use the "cache.app.taggable" adapter or give another tag aware adapter explicitly to the "tags" option. Using the "cache.app" adapter with the "tags" option will throw an exception in Symfony 8.0.');
1845+
1846+
$this->createContainerFromFile('cache_cacheapp_tagaware');
1847+
}
1848+
18361849
/**
18371850
* @dataProvider appRedisTagAwareConfigProvider
18381851
*/

0 commit comments

Comments
 (0)
0