diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index b5f6a61b56..84bb841d85 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -15,6 +15,7 @@ use Psr\Cache\CacheItemInterface; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\Exception\InvalidArgumentException; @@ -108,7 +109,9 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface } $apcu = new ApcuAdapter($namespace, (int) $defaultLifetime / 5, $version); - if (null !== $logger) { + if ('cli' === PHP_SAPI && !ini_get('apc.enable_cli')) { + $apcu->setLogger(new NullLogger()); + } elseif (null !== $logger) { $apcu->setLogger($logger); } diff --git a/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php b/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php index 6687bd4272..ad3aadf1a5 100644 --- a/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php @@ -50,7 +50,7 @@ class ApcuAdapter extends AbstractAdapter protected function doFetch(array $ids) { try { - return apcu_fetch($ids); + return apcu_fetch($ids) ?: array(); } catch (\Error $e) { throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); } @@ -92,7 +92,11 @@ class ApcuAdapter extends AbstractAdapter protected function doSave(array $values, $lifetime) { try { - return array_keys(apcu_store($values, null, $lifetime)); + if (false === $failures = apcu_store($values, null, $lifetime)) { + $failures = $values; + } + + return array_keys($failures); } catch (\Error $e) { } catch (\Exception $e) { }