Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f1d12a1

Browse filesBrowse files
bug #18485 [Cache] Workaround krakjoe/apcu#170 (nicolas-grekas)
This PR was merged into the 3.1-dev branch. Discussion ---------- [Cache] Workaround krakjoe/apcu#170 | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | krakjoe/apcu#170 | License | MIT | Doc PR | - Commits ------- 98dce41 [Cache] Workaround krakjoe/apcu#170
2 parents af9ec74 + 98dce41 commit f1d12a1
Copy full SHA for f1d12a1

File tree

Expand file treeCollapse file tree

2 files changed

+25
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+25
-1
lines changed

‎src/Symfony/Component/Cache/Adapter/ApcuAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/ApcuAdapter.php
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ protected function doDelete(array $ids)
7272
*/
7373
protected function doSave(array $values, $lifetime)
7474
{
75-
return array_keys(apcu_store($values, null, $lifetime));
75+
try {
76+
return array_keys(apcu_store($values, null, $lifetime));
77+
} catch (\Error $e) {
78+
} catch (\Exception $e) {
79+
}
80+
81+
if (1 === count($values)) {
82+
// Workaround https://github.com/krakjoe/apcu/issues/170
83+
apcu_delete(key($values));
84+
}
85+
86+
throw $e;
7687
}
7788
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Adapter/ApcuAdapterTest.php
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,17 @@ public function createCachePool()
3030

3131
return new ApcuAdapter(str_replace('\\', '.', __CLASS__));
3232
}
33+
34+
public function testUnserializable()
35+
{
36+
$pool = $this->createCachePool();
37+
38+
$item = $pool->getItem('foo');
39+
$item->set(function() {});
40+
41+
$this->assertFalse($pool->save($item));
42+
43+
$item = $pool->getItem('foo');
44+
$this->assertFalse($item->isHit());
45+
}
3346
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.