Skip to content

Commit 6d08d7f

Browse files
committed
bug symfony#25822 [Cache] Fix handling of apcu_fetch() edgy behavior (nicolas-grekas)
This PR was merged into the 3.3 branch. Discussion ---------- [Cache] Fix handling of apcu_fetch() edgy behavior | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Replaces symfony#25819. Cannot be tested as I don't know how to trigger this behavior. Commits ------- c707c4c [Cache] Fix handling of apcu_fetch() edgy behavior
2 parents 65b48b5 + c707c4c commit 6d08d7f

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)