From a2b06771202365af678df478eab4e68aa7006d68 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Nov 2012 15:09:46 +0200 Subject: Fix #18 --- system/libraries/Cache/drivers/Cache_apc.php | 15 +++++++++------ 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 ` didn't display information for database objects that are instantiated inside models. - Fixed a bug (#1978) - :doc:`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 ` didn't look for helper extensions in added package paths. +- Fixed a bug (#18) - :doc:`APC Cache ` driver didn't (un)serialize data, resulting in failure to store objects. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b