Skip to content

Commit 134781b

Browse files
committed
bug #19893 [FrameworkBundle] Remove cache clearer default value in config (nicolas-grekas)
This PR was merged into the 3.1 branch. Discussion ---------- [FrameworkBundle] Remove cache clearer default value in config | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | Tests pass? | yes | License | MIT `cache.default_clearer` is already the default behavior (tested), but duplicating this in the configuration prevents inheriting the `clearer` setting when configuring child pools. Commits ------- 193542f [FrameworkBundle] Remove cache clearer default value in config
2 parents d7a9bb9 + c025485 commit 134781b

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
585585
->scalarNode('provider')
586586
->info('The service name to use as provider when the specified adapter needs one.')
587587
->end()
588-
->scalarNode('clearer')->defaultValue('cache.default_clearer')->end()
588+
->scalarNode('clearer')->end()
589589
->end()
590590
->end()
591591
->validate()

Tests/Functional/CachePoolsTest.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,28 @@ public function doTestCachePools($options, $adapterClass)
6262
static::bootKernel($options);
6363
$container = static::$kernel->getContainer();
6464

65-
$pool = $container->get('cache.test');
66-
$this->assertInstanceOf($adapterClass, $pool);
65+
$pool1 = $container->get('cache.pool1');
66+
$this->assertInstanceOf($adapterClass, $pool1);
6767

6868
$key = 'foobar';
69-
$pool->deleteItem($key);
70-
$item = $pool->getItem($key);
69+
$pool1->deleteItem($key);
70+
$item = $pool1->getItem($key);
7171
$this->assertFalse($item->isHit());
7272

7373
$item->set('baz');
74-
$pool->save($item);
75-
$item = $pool->getItem($key);
74+
$pool1->save($item);
75+
$item = $pool1->getItem($key);
7676
$this->assertTrue($item->isHit());
7777

78+
$pool2 = $container->get('cache.pool2');
79+
$pool2->save($item);
80+
7881
$container->get('cache_clearer')->clear($container->getParameter('kernel.cache_dir'));
79-
$item = $pool->getItem($key);
82+
$item = $pool1->getItem($key);
8083
$this->assertFalse($item->isHit());
84+
85+
$item = $pool2->getItem($key);
86+
$this->assertTrue($item->isHit());
8187
}
8288

8389
protected static function createKernel(array $options = array())

Tests/Functional/app/CachePools/config.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@ imports:
44
framework:
55
cache:
66
pools:
7-
cache.test:
7+
cache.pool1:
88
public: true
9+
cache.pool2:
10+
public: true
11+
adapter: cache.pool3
12+
cache.pool3:
13+
clearer: ~

Tests/Functional/app/CachePools/redis_config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ framework:
55
cache:
66
app: cache.adapter.redis
77
pools:
8-
cache.test:
8+
cache.pool1:
99
public: true
10+
cache.pool2:
11+
public: true
12+
clearer: ~

Tests/Functional/app/CachePools/redis_custom_config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@ services:
1717
framework:
1818
cache:
1919
pools:
20-
cache.test:
20+
cache.pool1:
2121
public: true
22+
cache.pool2:
23+
public: true
24+
clearer: ~

0 commit comments

Comments
 (0)