8000 [Cache] skip APCu in chains when the backend is disabled · symfony/cache@c9f37a7 · GitHub
[go: up one dir, main page]

Skip to content

Commit c9f37a7

Browse files
[Cache] skip APCu in chains when the backend is disabled
1 parent b0f3fc7 commit c9f37a7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Adapter/AbstractAdapter.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Psr\Cache\CacheItemInterface;
1515
use Psr\Log\LoggerAwareInterface;
1616
use Psr\Log\LoggerInterface;
17-
use Psr\Log\NullLogger;
1817
use Symfony\Component\Cache\CacheItem;
1918
use Symfony\Component\Cache\Exception\InvalidArgumentException;
2019
use Symfony\Component\Cache\ResettableInterface;
@@ -116,14 +115,12 @@ public static function createSystemCache($namespace, $defaultLifetime, $version,
116115
if (null !== $logger) {
117116
$fs->setLogger($logger);
118117
}
119-
if (!self::$apcuSupported) {
118+
if (!self::$apcuSupported || (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))) {
120119
return $fs;
121120
}
122121

123122
$apcu = new ApcuAdapter($namespace, (int) $defaultLifetime / 5, $version);
124-
if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
125-
$apcu->setLogger(new NullLogger());
126-
} elseif (null !== $logger) {
123+
if (null !== $logger) {
127124
$apcu->setLogger($logger);
128125
}
129126

Adapter/ChainAdapter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public function __construct(array $adapters, $defaultLifetime = 0)
4646
if (!$adapter instanceof CacheItemPoolInterface) {
4747
throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', \get_class($adapter), CacheItemPoolInterface::class));
4848
}
49+
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && $adapter instanceof ApcuAdapter && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
50+
continue; // skip putting APCu in the chain when the backend is disabled
51+
}
4952

5053
if ($adapter instanceof AdapterInterface) {
5154
$this->adapters[] = $adapter;

0 commit comments

Comments
 (0)
0