Hi
It seems trying to cache an empty array will cause unserialize failed when retrieving.
memcached-tool dump showed results:
a:2:{i:0;a:0:{}i:1;N;}
trying Yii::app()->cache-get($key)
Yii unserialize() expects parameter 1 to be string, array given
See CCache.php Line 84, I modified
$data=unserialize($value);
To
if(!is_string($value))
{
$data = $value;
}
else
{
$data=unserialize($value);
}
Or add
if($value === false || ( is_array($value) && empty($value) ) )
return;
on line 144 to avoid set an empty array value.
I don’t know if it is the right way, just works.
Another question, I write a class named CacheManager, just a proxy call for Yii::app()->cache, like this
public function set($key, $value)
{
Yii::app()->cache->set($key, $value);
}
But I can find unserialized data in cache by this function call, calling Yii::app()->cache->set directly always store serialized data in cache, I don’t understand why, I had to add checks above to CCache.
any suggestions will be appreciated.