8000 bug #36555 [Cache] skip APCu in chains when the backend is disabled (… · symfony/symfony@259f523 · GitHub
[go: up one dir, main page]

Skip to content

Commit 259f523

Browse files
committed
bug #36555 [Cache] skip APCu in chains when the backend is disabled (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [Cache] skip APCu in chains when the backend is disabled | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #34962 | License | MIT | Doc PR | - I think this should do it. Commits ------- 5a72084 [Cache] skip APCu in chains when the backend is disabled
2 parents ea69f77 + 5a72084 commit 259f523

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Symfony/Component/Cache/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

src/Symfony/Component/Cache/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