Skip to content

Commit f2338ec

Browse files
committed
Merge pull request #44 from BaptN/master
Fixbug, refact. BC on sfCacheSessionStorage
2 parents 249b1c0 + 66cd6da commit f2338ec

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lib/storage/sfCacheSessionStorage.class.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,21 @@ public function initialize($options = array())
129129
{
130130
$this->data = array();
131131
}
132-
elseif (is_array($raw))
133-
{
134-
// probably an old cached value (BC)
135-
$this->data = $raw;
136-
}
137132
else
138133
{
139-
$this->data = unserialize($raw);
134+
$data = @unserialize($raw);
135+
// We test 'b:0' special case, because such a string would result
136+
// in $data being === false, while raw is serialized
137+
// see http://stackoverflow.com/questions/1369936/check-to-see-if-a-string-is-serialized
138+
if ( $raw === 'b:0;' || $data !== false)
139+
{
140+
$this->data = $data;
141+
}
142+
else
143+
{
144+
// Probably an old cached value (BC)
145+
$this->data = $raw;
146+
}
140147
}
141148

142149
if(sfConfig::get('sf_logging_enabled'))

0 commit comments

Comments
 (0)