Skip to content

[FrameworkBundle] Deprecate making cache.app adapter taggable #57927

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
Aug 13, 2024
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
1 change: 1 addition & 0 deletions UPGRADE-7.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +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

Form
----
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CHANGELOG
* Make the `config/` directory optional in `MicroKernelTrait`, add support for service arguments in the
invokable Kernel class, and register `FrameworkBundle` by default when the `bundles.php` file is missing
* [BC BREAK] The `secrets:decrypt-to-local` command terminates with a non-zero exit code when a secret could not be read
* Deprecate making `cache.app` adapter taggable, use the `cache.app.taggable` adapter instead

7.1
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2363,6 +2363,11 @@ 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).');
}

$pool['adapters'] = $pool['adapters'] ?: ['cache.app'];

$isRedisTagAware = ['cache.adapter.redis_tag_aware'] === $pool['adapters'];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$container->loadFromExtension('framework', [
'annotations' => false,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'cache' => [
'pools' => [
'app.tagaware' => [
'adapter' => 'cache.app',
'tags' => true,
],
],
],
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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 http-method-override="false" handle-all-throwables="true">
<framework:annotations enabled="false" />
<framework:php-errors log="true" />
<framework:cache>
<framework:pool name="app.tagaware" adapter="cache.app" tags="true" />
</framework:cache>
</framework:config>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
framework:
annotations: false
http_method_override: false
handle_all_throwables: true
php_errors:
log: true
cache:
pools:
app.tagaware:
adapter: cache.app
tags: true
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Psr\Cache\CacheItemPoolInterface;
use Psr\Log\LoggerAwareInterface;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage;
Expand Down Expand Up @@ -93,6 +94,8 @@

abstract class FrameworkExtensionTestCase extends TestCase
{
use ExpectDeprecationTrait;

private static array $containerCache = [];

abstract protected function loadFromFile(ContainerBuilder $container, $file);
Expand Down Expand Up @@ -1833,6 +1836,16 @@ public function testCacheTaggableTagAppliedToPools()
}
}

/**
* @group legacy
*/
public function testTaggableCacheAppIsDeprecated()
{
$this->expectDeprecation('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->createContainerFromFile('cache_cacheapp_tagaware');
}

/**
* @dataProvider appRedisTagAwareConfigProvider
*/
Expand Down
Loading