diff options
-rw-r--r-- | system/libraries/Cache/drivers/Cache_apc.php | 15 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 1 |
2 files changed, 10 insertions, 6 deletions
diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index 46e633463..a9ad6ed19 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -48,9 +48,11 @@ class CI_Cache_apc extends CI_Driver { */ public function get($id) { - $data = apc_fetch($id); + $success = FALSE; + $data = apc_fetch($id, $success); - return is_array($data) ? $data[0] : FALSE; + return ($success === TRUE && is_array($data)) + ? unserialize($data[0]) : FALSE; } // ------------------------------------------------------------------------ @@ -67,7 +69,7 @@ class CI_Cache_apc extends CI_Driver { public function save($id, $data, $ttl = 60) { $ttl = (int) $ttl; - return apc_store($id, array($data, time(), $ttl), $ttl); + return apc_store($id, array(serialize($data), time(), $ttl), $ttl); } // ------------------------------------------------------------------------ @@ -118,9 +120,10 @@ class CI_Cache_apc extends CI_Driver { */ public function get_metadata($id) { - $stored = apc_fetch($id); + $success = FALSE; + $stored = apc_fetch($id, $success); - if (count($stored) !== 3) + if ($success === FALSE OR count($stored) !== 3) { return FALSE; } @@ -130,7 +133,7 @@ class CI_Cache_apc extends CI_Driver { return array( 'expire' => $time + $ttl, 'mtime' => $time, - 'data' => $data + 'data' => unserialize($data) ); } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 55927f219..6047f1c9c 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -447,6 +447,7 @@ Bug fixes for 3.0 - Fixed a bug (#1220) - :doc:`Profiler Library <general/profiling>` didn't display information for database objects that are instantiated inside models. - Fixed a bug (#1978) - :doc:`Directory Helper <helpers/directory_helper>` function :php:func:`directory_map()`'s return array didn't make a distinction between directories and file indexes when a directory with a numeric name is present. - Fixed a bug (#777) - :doc:`Loader Library <libraries/loader>` didn't look for helper extensions in added package paths. +- Fixed a bug (#18) - :doc:`APC Cache <libraries/caching>` driver didn't (un)serialize data, resulting in failure to store objects. Version 2.1.3 ============= |