From c15618bcc2e368b88d3e3632ae24cf6f088d78f7 Mon Sep 17 00:00:00 2001 From: Jonas Elfering Date: Mon, 11 Nov 2024 16:44:01 +0100 Subject: [PATCH 1/2] Fix deprecation for cache.app adapter with tags Fixes https://github.com/symfony/symfony/issues/58790 --- UPGRADE-7.2.md | 2 +- .../DependencyInjection/FrameworkExtension.php | 6 +++--- .../Fixtures/php/cache_cacheapp_tagaware.php | 3 +-- .../Fixtures/xml/cache_cacheapp_tagaware.xml | 2 +- .../Fixtures/yml/cache_cacheapp_tagaware.yml | 3 +-- .../DependencyInjection/FrameworkExtensionTestCase.php | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/UPGRADE-7.2.md b/UPGRADE-7.2.md index 1f77b3e2964df..43c334fc2e141 100644 --- a/UPGRADE-7.2.md +++ b/UPGRADE-7.2.md @@ -12,7 +12,7 @@ Cache ----- * `igbinary_serialize()` is not used by default when the igbinary extension is installed - * Deprecate making `cache.app` adapter taggable, use the `cache.app.taggable` adapter instead + * Deprecate making `cache.app` pool taggable, use the `cache.app.taggable` pool instead Console ------- diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index a7749cd30faad..7d0aec5f61dff 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -2396,9 +2396,9 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con ]; } foreach ($config['pools'] as $name => $pool) { - if (\in_array('cache.app', $pool['adapters'] ?? [], true) && $pool['tags']) { - trigger_deprecation('symfony/framework-bundle', '7.2', 'Using the "tags" option with the "cache.app" adapter is deprecated. You can use the "cache.app.taggable" adapter instead (aliased to the TagAwareCacheInterface for autowiring).'); - // throw new LogicException('The "tags" option cannot be used with the "cache.app" adapter. You can use the "cache.app.taggable" adapter instead (aliased to the TagAwareCacheInterface for autowiring).'); + if ('cache.app' === $name && $pool['tags']) { + trigger_deprecation('symfony/framework-bundle', '7.2', 'Using the "tags" option with the "cache.app" pool is deprecated. You can use the "cache.app.taggable" pool instead (aliased to the TagAwareCacheInterface for autowiring).'); + // throw new LogicException('The "tags" option cannot be used with the "cache.app" pool. You can use the "cache.app.taggable" pool instead (aliased to the TagAwareCacheInterface for autowiring).'); } $pool['adapters'] = $pool['adapters'] ?: ['cache.app']; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_cacheapp_tagaware.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_cacheapp_tagaware.php index 77606f5b144bd..f82df1619939d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_cacheapp_tagaware.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_cacheapp_tagaware.php @@ -7,8 +7,7 @@ 'php_errors' => ['log' => true], 'cache' => [ 'pools' => [ - 'app.tagaware' => [ - 'adapter' => 'cache.app', + 'cache.app' => [ 'tags' => true, ], ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_cacheapp_tagaware.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_cacheapp_tagaware.xml index 7d59e19d514b8..e636b91341dd1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_cacheapp_tagaware.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_cacheapp_tagaware.xml @@ -9,7 +9,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_cacheapp_tagaware.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_cacheapp_tagaware.yml index 32ef3d49cdfc9..6ab14e9cca014 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_cacheapp_tagaware.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_cacheapp_tagaware.yml @@ -6,6 +6,5 @@ framework: log: true cache: pools: - app.tagaware: - adapter: cache.app + cache.app: tags: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php index 016ae507badc8..1ee24be3ed8f6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -1861,7 +1861,7 @@ public function testCacheTaggableTagAppliedToPools() */ public function testTaggableCacheAppIsDeprecated() { - $this->expectUserDeprecationMessage('Since symfony/framework-bundle 7.2: Using the "tags" option with the "cache.app" adapter is deprecated. You can use the "cache.app.taggable" adapter instead (aliased to the TagAwareCacheInterface for autowiring).'); + $this->expectUserDeprecationMessage('Since symfony/framework-bundle 7.2: Using the "tags" option with the "cache.app" pool is deprecated. You can use the "cache.app.taggable" pool instead (aliased to the TagAwareCacheInterface for autowiring).'); $this->createContainerFromFile('cache_cacheapp_tagaware'); } From f2cb2178b5328b584243b42d7314d035b31211e0 Mon Sep 17 00:00:00 2001 From: Jonas Elfering Date: Tue, 12 Nov 2024 15:25:57 +0100 Subject: [PATCH 2/2] Deprecate cache.app configuration as tag aware --- UPGRADE-7.2.md | 2 +- .../DependencyInjection/FrameworkExtension.php | 15 ++++++++++----- .../Fixtures/php/cache_cacheapp_tagaware.php | 6 +----- .../Fixtures/xml/cache_cacheapp_tagaware.xml | 4 +--- .../Fixtures/yml/cache_cacheapp_tagaware.yml | 4 +--- .../FrameworkExtensionTestCase.php | 2 +- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/UPGRADE-7.2.md b/UPGRADE-7.2.md index 43c334fc2e141..1267b2a07299f 100644 --- a/UPGRADE-7.2.md +++ b/UPGRADE-7.2.md @@ -12,7 +12,7 @@ Cache ----- * `igbinary_serialize()` is not used by default when the igbinary extension is installed - * Deprecate making `cache.app` pool taggable, use the `cache.app.taggable` pool instead + * Deprecate making `cache.app` tag aware, use the `cache.app.taggable` service instead Console ------- diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 7d0aec5f61dff..703151ae64978 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -2389,6 +2389,16 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con } } foreach (['app', 'system'] as $name) { + if ('cache.adapter.redis_tag_aware' === $config[$name]) { + trigger_deprecation('symfony/framework-bundle', '7.2', sprintf( + 'Using the "cache.adapter.redis_tag_aware" adapter for "cache.%s" is deprecated. You can use the "cache.app.taggable" service instead (aliased to the TagAwareCacheInterface for autowiring).', + $name + )); + // throw new LogicException(sprintf( + // 'Using the "cache.adapter.redis_tag_aware" adapter for "cache.%s" is deprecated. You can use the "cache.app.taggable" service instead (aliased to the TagAwareCacheInterface for autowiring).', + // $name + // )); + } $config['pools']['cache.'.$name] = [ 'adapters' => [$config[$name]], 'public' => true, @@ -2396,11 +2406,6 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con ]; } foreach ($config['pools'] as $name => $pool) { - if ('cache.app' === $name && $pool['tags']) { - trigger_deprecation('symfony/framework-bundle', '7.2', 'Using the "tags" option with the "cache.app" pool is deprecated. You can use the "cache.app.taggable" pool instead (aliased to the TagAwareCacheInterface for autowiring).'); - // throw new LogicException('The "tags" option cannot be used with the "cache.app" pool. You can use the "cache.app.taggable" pool instead (aliased to the TagAwareCacheInterface for autowiring).'); - } - $pool['adapters'] = $pool['adapters'] ?: ['cache.app']; $isRedisTagAware = ['cache.adapter.redis_tag_aware'] === $pool['adapters']; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_cacheapp_tagaware.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_cacheapp_tagaware.php index f82df1619939d..604b03c9fc5aa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_cacheapp_tagaware.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/cache_cacheapp_tagaware.php @@ -6,10 +6,6 @@ 'handle_all_throwables' => true, 'php_errors' => ['log' => true], 'cache' => [ - 'pools' => [ - 'cache.app' => [ - 'tags' => true, - ], - ], + 'app' => 'cache.adapter.redis_tag_aware', ], ]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_cacheapp_tagaware.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_cacheapp_tagaware.xml index e636b91341dd1..004912abee095 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_cacheapp_tagaware.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/cache_cacheapp_tagaware.xml @@ -8,8 +8,6 @@ - - - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_cacheapp_tagaware.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_cacheapp_tagaware.yml index 6ab14e9cca014..c19943a8ea253 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_cacheapp_tagaware.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/cache_cacheapp_tagaware.yml @@ -5,6 +5,4 @@ framework: php_errors: log: true cache: - pools: - cache.app: - tags: true + app: cache.adapter.redis_tag_aware diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php index 1ee24be3ed8f6..9c29494e1e8cd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -1861,7 +1861,7 @@ public function testCacheTaggableTagAppliedToPools() */ public function testTaggableCacheAppIsDeprecated() { - $this->expectUserDeprecationMessage('Since symfony/framework-bundle 7.2: Using the "tags" option with the "cache.app" pool is deprecated. You can use the "cache.app.taggable" pool instead (aliased to the TagAwareCacheInterface for autowiring).'); + $this->expectUserDeprecationMessage('Since symfony/framework-bundle 7.2: Using the "cache.adapter.redis_tag_aware" adapter for "cache.app" is deprecated. You can use the "cache.app.taggable" service instead (aliased to the TagAwareCacheInterface for autowiring).'); $this->createContainerFromFile('cache_cacheapp_tagaware'); }