8000 [Cache] Unconditionally use PhpFilesAdapter for system pools · symfony/symfony@8cf36c7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8cf36c7

Browse files
[Cache] Unconditionally use PhpFilesAdapter for system pools
1 parent 50c4384 commit 8cf36c7

File tree

6 files changed

+12
-26
lines changed

6 files changed

+12
-26
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolClearerPass.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14-
use Symfony\Component\Cache\Adapter\AbstractAdapter;
1514
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1615
use Symfony\Component\DependencyInjection\ContainerBuilder;
1716
use Symfony\Component\DependencyInjection\Reference;
@@ -38,22 +37,5 @@ public function process(ContainerBuilder $container)
3837
}
3938
$clearer->replaceArgument(0, $pools);
4039
}
41-
42-
if (!$container->has('cache.annotations')) {
43-
return;
44-
}
45-
$factory = array(AbstractAdapter::class, 'createSystemCache');
46-
$annotationsPool = $container->findDefinition('cache.annotations');
47-
if ($factory !== $annotationsPool->getFactory() || 4 !== count($annotationsPool->getArguments())) {
48-
return;
49-
}
50-
if ($container->has('monolog.logger.cache')) {
51-
$annotationsPool->addArgument(new Reference('monolog.logger.cache'));
52-
} elseif ($container->has('cache.system')) {
53-
$systemPool = $container->findDefinition('cache.system');
54-
if ($factory === $systemPool->getFactory() && 5 <= count($systemArgs = $systemPool->getArguments())) {
55-
$annotationsPool->addArgument($systemArgs[4]);
56-
}
57-
}
5840
}
5941
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,6 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
15381538
{
15391539
$version = new Parameter('container.build_id');
15401540
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $version);
1541-
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $version);
15421541
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']);
15431542

15441543
if (isset($config['prefix_seed'])) {

src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@
3535
<tag name="cache.pool" />
3636
</service>
3737

38-
<service id="cache.adapter.system" class="Symfony\Component\Cache\Adapter\AdapterInterface" abstract="true">
39-
<factory class="Symfony\Component\Cache\Adapter\AbstractAdapter" method="createSystemCache" />
38+
<service id="cache.adapter.system" class="Symfony\Component\Cache\Adapter\PhpFilesAdapter" abstract="true">
4039
<tag name="cache.pool" clearer="cache.system_clearer" />
4140
<tag name="monolog.logger" channel="cache" />
4241
<argument /> <!-- namespace -->
4342
<argument>0</argument> <!-- default lifetime -->
44-
<argument /> <!-- version -->
4543
<argument>%kernel.cache_dir%/pools</argument>
46-
<argument type="service" id="logger" on-invalid="ignore" />
44+
<call method="setLogger">
45+
<argument type="service" id="logger" on-invalid="ignore" />
46+
</call>
4747
</service>
4848

4949
<service id="cache.adapter.apcu" class="Symfony\Component\Cache\Adapter\ApcuAdapter" abstract="true">

src/Symfony/Component/Cache/Adapter/AbstractAdapter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,13 @@ function ($deferred, $namespace, &$expiredIds) use ($getId) {
8787
* @param LoggerInterface|null $logger
8888
*
8989
* @return AdapterInterface
90+
*
91+
* @deprecated since Symfony 4.2.
9092
*/
9193
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null)
9294
{
95+
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED);
96+
9397
if (null === self::$apcuSupported) {
9498
self::$apcuSupported = ApcuAdapter::isSupported();
9599
}

src/Symfony/Component/Cache/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* added `CacheInterface`, which should become the preferred way to use a cache
88
* throw `LogicException` when `CacheItem::tag()` is called on an item coming from a non tag-aware pool
9+
* deprecated the `AbstractAdapter::createSystemCache()` method
910

1011
3.4.0
1112
-----

src/Symfony/Component/Cache/Traits/PhpFilesTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ trait PhpFilesTrait
3030

3131
public static function isSupported()
3232
{
33-
return function_exists('opcache_invalidate') && ini_get('opcache.enable');
33+
return \function_exists('opcache_invalidate') && ini_get('opcache.enable');
3434
}
3535

3636
/**
@@ -40,7 +40,7 @@ public function prune()
4040
{
4141
$time = time();
4242
$pruned = true;
43-
$allowCompile = 'cli' !== PHP_SAPI || ini_get('opcache.enable_cli');
43+
$allowCompile = \function_exists('opcache_invalidate') && ('cli' !== \PHP_SAPI || ini_get('opcache.enable_cli'));
4444

4545
set_error_handler($this->includeHandler);
4646
try {
@@ -119,7 +119,7 @@ protected function doSave(array $values, $lifetime)
119119
{
120120
$ok = true;
121121
$data = array($lifetime ? time() + $lifetime : PHP_INT_MAX, '');
122-
$allowCompile = 'cli' !== PHP_SAPI || ini_get('opcache.enable_cli');
122+
$allowCompile = \function_exists('opcache_invalidate') && ('cli' !== \PHP_SAPI || ini_get('opcache.enable_cli'));
123123

124124
foreach ($values as $key => $value) {
125125
if (null === $value || \is_object($value)) {

0 commit comments

Comments
 (0)
0