File tree 2 files changed +25
-1
lines changed
src/Symfony/Component/Cache
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,17 @@ protected function doDelete(array $ids)
72
72
*/
73
73
protected function doSave (array $ values , $ lifetime )
74
74
{
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 ;
76
87
}
77
88
}
Original file line number Diff line number Diff line change @@ -30,4 +30,17 @@ public function createCachePool()
30
30
31
31
return new ApcuAdapter (str_replace ('\\' , '. ' , __CLASS__ ));
32
32
}
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
+ }
33
46
}
You can’t perform that action at this time.
0 commit comments