Skip to content

[FrameworkBundle] Don't clear app pools on cache:clear #24383

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
Oct 1, 2017
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
4 changes: 4 additions & 0 deletions UPGRADE-3.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ Form
FrameworkBundle
---------------

* The `cache:clear` command doesn't clear "app" PSR-6 cache pools anymore,
but still clears "system" ones.
Use the `cache:pool:clear` command to clear "app" pools instead.

* The `doctrine/cache` dependency has been removed; require it via `composer
require doctrine/cache` if you are using Doctrine cache in your project.

Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ CHANGELOG
3.4.0
-----

* Made the `cache:clear` command to *not* clear "app" PSR-6 cache pools anymore,
but to still clear "system" ones; use the `cache:pool:clear` command to clear "app" pools instead
* Always register a minimalist logger that writes in `stderr`
* Deprecated `profiler.matcher` option
* Added support for `EventSubscriberInterface` on `MicroKernelTrait`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function process(ContainerBuilder $container)

foreach ($clearers as $id => $pools) {
$clearer = $container->getDefinition($id);
if ($clearer instanceof ChilDefinition) {
if ($clearer instanceof ChildDefinition) {
$clearer->replaceArgument(0, $pools);
} else {
$clearer->setArgument(0, $pools);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,7 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
if (!$container->getParameter('kernel.debug')) {
$propertyAccessDefinition->setFactory(array(PropertyAccessor::class, 'createCache'));
$propertyAccessDefinition->setArguments(array(null, null, $version, new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)));
$propertyAccessDefinition->addTag('cache.pool', array('clearer' => 'cache.default_clearer'));
$propertyAccessDefinition->addTag('cache.pool', array('clearer' => 'cache.system_clearer'));
$propertyAccessDefinition->addTag('monolog.logger', array('channel' => 'cache'));
} else {
$propertyAccessDefinition->setClass(ArrayAdapter::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<service id="cache.adapter.system" class="Symfony\Component\Cache\Adapter\AdapterInterface" abstract="true">
<factory class="Symfony\Component\Cache\Adapter\AbstractAdapter" method="createSystemCache" />
<tag name="cache.pool" clearer="cache.default_clearer" />
<tag name="cache.pool" clearer="cache.system_clearer" />
<tag name="monolog.logger" channel="cache" />
<argument /> <!-- namespace -->
<argument>0</argument> <!-- default lifetime -->
Expand Down Expand Up @@ -101,6 +101,10 @@
</service>

<service id="cache.default_clearer" class="Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer">
<argument type="collection" />
</service>

<service id="cache.system_clearer" parent="cache.default_clearer" public="true">
<tag name="kernel.cache_clearer" />
</service>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;

use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Exception\InvalidArgumentException;

class CachePoolsTest extends WebTestCase
{
public function testCachePools()
{
$this->doTestCachePools(array(), FilesystemAdapter::class);
$this->doTestCachePools(array(), AdapterInterface::class);
}

/**
Expand Down Expand Up @@ -67,7 +67,7 @@ public function testRedisCustomCachePools()
}
}

public function doTestCachePools($options, $adapterClass)
private function doTestCachePools($options, $adapterClass)
{
static::bootKernel($options);
$container = static::$kernel->getContainer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ framework:
pools:
cache.pool1:
public: true
adapter: cache.system
cache.pool2:
public: true
adapter: cache.pool3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ framework:
pools:
cache.pool1:
public: true
clearer: cache.system_clearer
cache.pool2:
public: true
clearer: ~
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ framework:
pools:
cache.pool1:
public: true
clearer: cache.system_clearer
cache.pool2:
public: true
clearer: ~