Skip to content

[Cache] ApcuAdapter::isSupported() should return true when apc.enable_cli=Off #23091

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
Jun 9, 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: 2 additions & 2 deletions src/Symfony/Component/Cache/Adapter/ApcuAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ApcuAdapter extends AbstractAdapter
{
public static function isSupported()
{
return function_exists('apcu_fetch') && ini_get('apc.enabled') && !('cli' === PHP_SAPI && !ini_get('apc.enable_cli'));
return function_exists('apcu_fetch') && ini_get('apc.enabled');
}

public function __construct($namespace = '', $defaultLifetime = 0, $version = null)
Expand Down Expand Up @@ -69,7 +69,7 @@ protected function doHave($id)
*/
protected function doClear($namespace)
{
return isset($namespace[0]) && class_exists('APCuIterator', false)
return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== PHP_SAPI || ini_get('apc.enable_cli'))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new APCuIterator triggers a fatal error when apcu is not enabled...

? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), APC_ITER_KEY))
: apcu_clear_cache();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PhpFilesAdapter extends AbstractAdapter

public static function isSupported()
{
return function_exists('opcache_compile_file') && ini_get('opcache.enable');
return function_exists('opcache_invalidate') && ini_get('opcache.enable');
}

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

if ($allowCompile) {
@opcache_compile_file($file);
@opcache_invalidate($file, true);
Copy link
Member Author

@nicolas-grekas nicolas-grekas Jun 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just verified with @jpauli: opcache_compile_file does not invalidate. Let's call only opcache_invalidate.

}
}

Expand Down