Skip to content

Commit

Permalink
bug #25822 [Cache] Fix handling of apcu_fetch() edgy behavior (nicola…
Browse files Browse the repository at this point in the history
…s-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 #25819. Cannot be tested as I don't know how to trigger this behavior.

Commits
-------

c707c4c [Cache] Fix handling of apcu_fetch() edgy behavior
  • Loading branch information
fabpot committed Jan 17, 2018
2 parents 65b48b5 + c707c4c commit 6d08d7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Expand Up @@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion src/Symfony/Component/Cache/Traits/ApcuTrait.php
Expand Up @@ -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());
}
Expand Down

0 comments on commit 6d08d7f

Please sign in to comment.