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
This commit is contained in:
Fabien Potencier 2016-09-13 17:01:35 -07:00
commit c2b660dc60
5 changed files with 28 additions and 11 deletions

View File

@ -585,7 +585,7 @@ class Configuration implements ConfigurationInterface
->scalarNode('provider')
->info('The service name to use as provider when the specified adapter needs one.')
->end()
->scalarNode('clearer')->defaultValue('cache.default_clearer')->end()
->scalarNode('clearer')->end()
->end()
->end()
->validate()

View File

@ -62,22 +62,28 @@ class CachePoolsTest extends WebTestCase
static::bootKernel($options);
$container = static::$kernel->getContainer();
$pool = $container->get('cache.test');
$this->assertInstanceOf($adapterClass, $pool);
$pool1 = $container->get('cache.pool1');
$this->assertInstanceOf($adapterClass, $pool1);
$key = 'foobar';
$pool->deleteItem($key);
$item = $pool->getItem($key);
$pool1->deleteItem($key);
$item = $pool1->getItem($key);
$this->assertFalse($item->isHit());
$item->set('baz');
$pool->save($item);
$item = $pool->getItem($key);
$pool1->save($item);
$item = $pool1->getItem($key);
$this->assertTrue($item->isHit());
$pool2 = $container->get('cache.pool2');
$pool2->save($item);
$container->get('cache_clearer')->clear($container->getParameter('kernel.cache_dir'));
$item = $pool->getItem($key);
$item = $pool1->getItem($key);
$this->assertFalse($item->isHit());
$item = $pool2->getItem($key);
$this->assertTrue($item->isHit());
}
protected static function createKernel(array $options = array())

View File

@ -4,5 +4,10 @@ imports:
framework:
cache:
pools:
cache.test:
cache.pool1:
public: true
cache.pool2:
public: true
adapter: cache.pool3
cache.pool3:
clearer: ~

View File

@ -5,5 +5,8 @@ framework:
cache:
app: cache.adapter.redis
pools:
cache.test:
cache.pool1:
public: true
cache.pool2:
public: true
clearer: ~

View File

@ -17,5 +17,8 @@ services:
framework:
cache:
pools:
cache.test:
cache.pool1:
public: true
cache.pool2:
public: true
clearer: ~