Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7e4494

Browse files
bug #44682 [FrameworkBundle] alias cache.app.taggable to cache.app if using cache.adapter.redis_tag_aware (kbond)
This PR was merged into the 5.3 branch. Discussion ---------- [FrameworkBundle] alias `cache.app.taggable` to `cache.app` if using `cache.adapter.redis_tag_aware` | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | n/a | License | MIT | Doc PR | n/a When using `cache.adapter.redis_tag_aware` for your `cache.app`, `cache.app.taggable` is unnecessarily decorated with `TagAwareAdapter`. This sets `cache.app.taggable` as an alias to `cache.app` in this case. Alternative to #44673. Commits ------- 4b54aa0 alias `cache.app.taggable` to `cache.app` if using `cache.adapter.redis_tag_aware`
2 parents f190e9e + 4b54aa0 commit a7e4494

8 files changed

+90
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2153,7 +2153,9 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
21532153
$pool['reset'] = 'reset';
21542154
}
21552155

2156-
if ($isRedisTagAware) {
2156+
if ($isRedisTagAware && 'cache.app' === $name) {
2157+
$container->setAlias('cache.app.taggable', $name);
2158+
} elseif ($isRedisTagAware) {
21572159
$tagAwareId = $name;
21582160
$container->setAlias('.'.$name.'.inner', $name);
21592161
} elseif ($pool['tags']) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', [
4+
'cache' => [
5+
'app' => 'cache.adapter.redis_tag_aware',
6+
],
7+
]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', [
4+
'cache' => [
5+
'app' => 'cache.redis_tag_aware.bar',
6+
'pools' => [
7+
'cache.redis_tag_aware.foo' => [
8+
'adapter' => 'cache.adapter.redis_tag_aware',
9+
],
10+
'cache.redis_tag_aware.bar' => [
11+
'adapter' => 'cache.redis_tag_aware.foo',
12+
],
13+
],
14+
],
15+
]);
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:app>cache.adapter.redis_tag_aware</framework:app>
11+
</framework:cache>
12+
</framework:config>
13+
</container>
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>
9+
<framework:cache>
10+
<framework:app>cache.redis_tag_aware.bar</framework:app>
11+
<framework:pool name="cache.redis_tag_aware.foo" adapter="cache.adapter.redis_tag_aware" />
12+
<framework:pool name="cache.redis_tag_aware.bar" adapter="cache.redis_tag_aware.foo" />
13+
</framework:cache>
14+
</framework:config>
15+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework:
2+
cache:
3+
app: cache.adapter.redis_tag_aware
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
framework:
2+
cache:
3+
app: cache.redis_tag_aware.bar
4+
pools:
5+
cache.redis_tag_aware.foo:
6+
adapter: cache.adapter.redis_tag_aware
7+
cache.redis_tag_aware.bar:
8+
adapter: cache.redis_tag_aware.foo

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,32 @@ public function testRedisTagAwareAdapter()
15871587
}
15881588
}
15891589

1590+
/**
1591+
* @dataProvider testAppRedisTagAwareConfigProvider
1592+
*/
1593+
public function testAppRedisTagAwareAdapter()
1594+
{
1595+
$container = $this->createContainerFromFile('cache_app_redis_tag_aware');
1596+
1597+
foreach ([TagAwareCacheInterface::class, CacheInterface::class, CacheItemPoolInterface::class] as $alias) {
1598+
$def = $container->findDefinition($alias);
1599+
1600+
while ($def instanceof ChildDefinition) {
1601+
$def = $container->getDefinition($def->getParent());
1602+
}
1603+
1604+
$this->assertSame(RedisTagAwareAdapter::class, $def->getClass());
1605+
}
1606+
}
1607+
1608+
public function testAppRedisTagAwareConfigProvider(): array
1609+
{
1610+
return [
1611+
['cache_app_redis_tag_aware'],
1612+
['cache_app_redis_tag_aware_pool'],
1613+
];
1614+
}
1615+
15901616
public function testRemovesResourceCheckerConfigCacheFactoryArgumentOnlyIfNoDebug()
15911617
{
15921618
$container = $this->createContainer(['kernel.debug' => true]);

0 commit comments

Comments
 (0)