From c707c4c4556d87e508737110bdf2dadce587ee0f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 17 Jan 2018 14:30:10 +0100 Subject: [PATCH] [Cache] Fix handling of apcu_fetch() edgy behavior --- .../Component/Cache/Tests/Adapter/ApcuAdapterTest.php | 2 +- src/Symfony/Component/Cache/Traits/ApcuTrait.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php index 75b3fa299ec2..72df12e4b593 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php @@ -29,7 +29,7 @@ public function createCachePool($defaultLifetime = 0) } if ('cli' === PHP_SAPI && !ini_get('apc.enable_cli')) { if ('testWithCliSapi' !== $this->getName()) { - $this->markTestSkipped('APCu extension is required.'); + $this->markTestSkipped('apc.enable_cli=1 is required.'); } } if ('\\' === DIRECTORY_SEPARATOR) { diff --git a/src/Symfony/Component/Cache/Traits/ApcuTrait.php b/src/Symfony/Component/Cache/Traits/ApcuTrait.php index 5614b390cf2f..fe7dfbab7d8c 100644 --- a/src/Symfony/Component/Cache/Traits/ApcuTrait.php +++ b/src/Symfony/Component/Cache/Traits/ApcuTrait.php @@ -52,7 +52,11 @@ private function init($namespace, $defaultLifetime, $version) protected function doFetch(array $ids) { try { - return apcu_fetch($ids) ?: array(); + foreach (apcu_fetch($ids, $ok) ?: array() as $k => $v) { + if (null !== $v || $ok) { + yield $k => $v; + } + } } catch (\Error $e) { throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); }