Skip to content

Commit c707c4c

Browse files
[Cache] Fix handling of apcu_fetch() edgy behavior
1 parent 65b48b5 commit c707c4c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function createCachePool($defaultLifetime = 0)
2929
}
3030
if ('cli' === PHP_SAPI && !ini_get('apc.enable_cli')) {
3131
if ('testWithCliSapi' !== $this->getName()) {
32-
$this->markTestSkipped('APCu extension is required.');
32+
$this->markTestSkipped('apc.enable_cli=1 is required.');
3333
}
3434
}
3535
if ('\\' === DIRECTORY_SEPARATOR) {

src/Symfony/Component/Cache/Traits/ApcuTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ private function init($namespace, $defaultLifetime, $version)
5252
protected function doFetch(array $ids)
5353
{
5454
try {
55-
return apcu_fetch($ids) ?: array();
55+
foreach (apcu_fetch($ids, $ok) ?: array() as $k => $v) {
56+
if (null !== $v || $ok) {
57+
yield $k => $v;
58+
}
59+
}
5660
} catch (\Error $e) {
5761
throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
5862
}

0 commit comments

Comments
 (0)