Permalink
Browse files

Fix #18

  • Loading branch information...
1 parent 52e7b24 commit a2b06771202365af678df478eab4e68aa7006d68 @narfbg narfbg committed Nov 20, 2012
Showing with 10 additions and 6 deletions.
  1. +9 −6 system/libraries/Cache/drivers/Cache_apc.php
  2. +1 −0 user_guide_src/source/changelog.rst
@@ -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 @@ public function get($id)
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 @@ public function cache_info($type = NULL)
*/
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 @@ public function get_metadata($id)
return array(
'expire' => $time + $ttl,
'mtime' => $time,
- 'data' => $data
+ 'data' => unserialize($data)
);
}
@@ -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
=============

0 comments on commit a2b0677

Please sign in to comment.