File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
src/Symfony/
8000
Component/Cache Expand file tree Collapse file tree 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)
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}
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments