Skip to content

Commit 40beab4

Browse files
committed
bug #23091 [Cache] ApcuAdapter::isSupported() should return true when apc.enable_cli=Off (nicolas-grekas)
This PR was merged into the 3.2 branch. Discussion ---------- [Cache] ApcuAdapter::isSupported() should return true when apc.enable_cli=Off | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - By being sensitive to apc.enable_cli, CLI cache warmup is broken when the setting is set to off because a PhpFilesAdapter will be warmed up by the CLI, whereas the Web mode will look at the FilesystemAdapter pools, which will be empty. Commits ------- aadf263 [Cache] APCu isSupported() should return true when apc.enable_cli=Off
2 parents c297144 + aadf263 commit 40beab4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ApcuAdapter extends AbstractAdapter
2121
{
2222
public static function isSupported()
2323
{
24-
return function_exists('apcu_fetch') && ini_get('apc.enabled') && !('cli' === PHP_SAPI && !ini_get('apc.enable_cli'));
24+
return function_exists('apcu_fetch') && ini_get('apc.enabled');
2525
}
2626

2727
public function __construct($namespace = '', $defaultLifetime = 0, $version = null)
@@ -69,7 +69,7 @@ protected function doHave($id)
6969
*/
7070
protected function doClear($namespace)
7171
{
72-
return isset($namespace[0]) && class_exists('APCuIterator', false)
72+
return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== PHP_SAPI || ini_get('apc.enable_cli'))
7373
? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), APC_ITER_KEY))
7474
: apcu_clear_cache();
7575
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class PhpFilesAdapter extends AbstractAdapter
2626

2727
public static function isSupported()
2828
{
29-
return function_exists('opcache_compile_file') && ini_get('opcache.enable');
29+
return function_exists('opcache_invalidate') && ini_get('opcache.enable');
3030
}
3131

3232
public function __construct($namespace = '', $defaultLifetime = 0, $directory = null)
@@ -118,7 +118,7 @@ protected function doSave(array $values, $lifetime)
118118
$ok = $this->write($file, '<?php return '.var_export($data, true).';') && $ok;
119119

120120
if ($allowCompile) {
121-
@opcache_compile_file($file);
121+
@opcache_invalidate($file, true);
122122
}
123123
}
124124

0 commit comments

Comments
 (0)