From 66cd6da2acb25b0c12fd08e414c9048f62694ba0 Mon Sep 17 00:00:00 2001 From: Baptiste Naudinat Date: Mon, 3 Mar 2014 17:43:11 +0100 Subject: [PATCH] Fixbug, refact. BC on sfCacheSessionStorage --- lib/storage/sfCacheSessionStorage.class.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/storage/sfCacheSessionStorage.class.php b/lib/storage/sfCacheSessionStorage.class.php index 00d602b12..eeedc8e68 100644 --- a/lib/storage/sfCacheSessionStorage.class.php +++ b/lib/storage/sfCacheSessionStorage.class.php @@ -129,14 +129,21 @@ public function initialize($options = array()) { $this->data = array(); } - elseif (is_array($raw)) - { - // probably an old cached value (BC) - $this->data = $raw; - } else { - $this->data = unserialize($raw); + $data = @unserialize($raw); + // We test 'b:0' special case, because such a string would result + // in $data being === false, while raw is serialized + // see http://stackoverflow.com/questions/1369936/check-to-see-if-a-string-is-serialized + if ( $raw === 'b:0;' || $data !== false) + { + $this->data = $data; + } + else + { + // Probably an old cached value (BC) + $this->data = $raw; + } } if(sfConfig::get('sf_logging_enabled'))