summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorctrlaltca@gmail.com <>2011-07-16 22:37:30 +0000
committerctrlaltca@gmail.com <>2011-07-16 22:37:30 +0000
commit920f78939adcdb62f5e6ac9368928bd3a0fa41fc (patch)
tree041a05cfb0efc62a19ff3d867546c13edc730bae
parent086387ec68df8c39ed2580a55b32f909fd092f18 (diff)
test patch for #179
-rw-r--r--framework/Caching/TAPCCache.php2
-rw-r--r--framework/Caching/TCache.php13
-rw-r--r--framework/Caching/TDbCache.php6
-rw-r--r--framework/Caching/TSqliteCache.php10
-rw-r--r--framework/PradoBase.php6
5 files changed, 17 insertions, 20 deletions
diff --git a/framework/Caching/TAPCCache.php b/framework/Caching/TAPCCache.php
index 20715d9b..84a79315 100644
--- a/framework/Caching/TAPCCache.php
+++ b/framework/Caching/TAPCCache.php
@@ -4,7 +4,7 @@
*
* @author Alban Hanry <compte_messagerie@hotmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2011 PradoSoft
+ * @copyright Copyright &copy; 2005-2011 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Caching
diff --git a/framework/Caching/TCache.php b/framework/Caching/TCache.php
index 39f3e780..57bdb4db 100644
--- a/framework/Caching/TCache.php
+++ b/framework/Caching/TCache.php
@@ -122,9 +122,8 @@ abstract class TCache extends TModule implements ICache, ArrayAccess
*/
public function get($id)
{
- if(($value=$this->getValue($this->generateUniqueKey($id)))!==false)
+ if(($data=$this->getValue($this->generateUniqueKey($id)))!==false)
{
- $data=unserialize($value);
if(!is_array($data))
return false;
if(!($data[1] instanceof ICacheDependency) || !$data[1]->getHasChanged())
@@ -152,7 +151,7 @@ abstract class TCache extends TModule implements ICache, ArrayAccess
else
{
$data=array($value,$dependency);
- return $this->setValue($this->generateUniqueKey($id),serialize($data),$expire);
+ return $this->setValue($this->generateUniqueKey($id),$data,$expire);
}
}
@@ -170,7 +169,7 @@ abstract class TCache extends TModule implements ICache, ArrayAccess
if(empty($value) && $expire === 0)
return false;
$data=array($value,$dependency);
- return $this->addValue($this->generateUniqueKey($id),serialize($data),$expire);
+ return $this->addValue($this->generateUniqueKey($id),$data,$expire);
}
/**
@@ -252,7 +251,7 @@ abstract class TCache extends TModule implements ICache, ArrayAccess
return $this->get($id) !== false;
}
- /*
+ /**
* Retrieves the value from cache with a specified key.
* This method is required by the interface ArrayAccess.
* @param string a key identifying the cached value
@@ -263,7 +262,7 @@ abstract class TCache extends TModule implements ICache, ArrayAccess
return $this->get($id);
}
- /*
+ /**
* Stores the value identified by a key into cache.
* If the cache already contains such a key, the existing value will be
* replaced with the new ones. To add expiration and dependencies, use the set() method.
@@ -276,7 +275,7 @@ abstract class TCache extends TModule implements ICache, ArrayAccess
$this->set($id, $value);
}
- /*
+ /**
* Deletes the value with the specified key from cache
* This method is required by the interface ArrayAccess.
* @param string the key of the value to be deleted
diff --git a/framework/Caching/TDbCache.php b/framework/Caching/TDbCache.php
index 9d1793e1..90aa88c6 100644
--- a/framework/Caching/TDbCache.php
+++ b/framework/Caching/TDbCache.php
@@ -466,12 +466,12 @@ class TDbCache extends TCache
try {
$sql='SELECT value FROM '.$this->_cacheTable.' WHERE itemkey=\''.$key.'\' AND (expire=0 OR expire>'.time().') ORDER BY expire DESC';
$command=$this->getDbConnection()->createCommand($sql);
- return $command->queryScalar();
+ return Prado::unserialize($command->queryScalar());
}
catch(Exception $e)
{
$this->initializeCache(true);
- return $command->queryScalar();
+ return Prado::unserialize($command->queryScalar());
}
}
@@ -508,7 +508,7 @@ class TDbCache extends TCache
{
$command=$this->getDbConnection()->createCommand($sql);
$command->bindValue(':key',$key,PDO::PARAM_STR);
- $command->bindValue(':value',$value,PDO::PARAM_LOB);
+ $command->bindValue(':value',Prado::serialize($value),PDO::PARAM_LOB);
$command->execute();
return true;
}
diff --git a/framework/Caching/TSqliteCache.php b/framework/Caching/TSqliteCache.php
index 4a1aa615..d4308e64 100644
--- a/framework/Caching/TSqliteCache.php
+++ b/framework/Caching/TSqliteCache.php
@@ -4,7 +4,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2011 PradoSoft
+ * @copyright Copyright &copy; 2005-2011 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Caching
@@ -18,7 +18,7 @@
* To use this module, the sqlite PHP extension must be loaded. Note, Sqlite extension
* is no longer loaded by default since PHP 5.1.
*
- * Sine PRADO v3.1.0, a new DB-based cache module called {@link TDbCache}
+ * Since PRADO v3.1.0, a new DB-based cache module called {@link TDbCache}
* is provided. If you have PDO extension installed, you may consider using
* the new cache module instead as it allows you to use different database
* to store the cached data.
@@ -162,7 +162,7 @@ class TSqliteCache extends TCache
{
$sql='SELECT value FROM '.self::CACHE_TABLE.' WHERE key=\''.$key.'\' AND (expire=0 OR expire>'.time().') LIMIT 1';
if(($ret=$this->_db->query($sql))!=false && ($row=$ret->fetch(SQLITE_ASSOC))!==false)
- return $row['value'];
+ return Prado::unserialize($row['value']);
else
return false;
}
@@ -179,7 +179,7 @@ class TSqliteCache extends TCache
protected function setValue($key,$value,$expire)
{
$expire=($expire<=0)?0:time()+$expire;
- $sql='REPLACE INTO '.self::CACHE_TABLE.' VALUES(\''.$key.'\',\''.sqlite_escape_string($value).'\','.$expire.')';
+ $sql='REPLACE INTO '.self::CACHE_TABLE.' VALUES(\''.$key.'\',\''.sqlite_escape_string(Prado::serialize($value)).'\','.$expire.')';
return $this->_db->query($sql)!==false;
}
@@ -195,7 +195,7 @@ class TSqliteCache extends TCache
protected function addValue($key,$value,$expire)
{
$expire=($expire<=0)?0:time()+$expire;
- $sql='INSERT INTO '.self::CACHE_TABLE.' VALUES(\''.$key.'\',\''.sqlite_escape_string($value).'\','.$expire.')';
+ $sql='INSERT INTO '.self::CACHE_TABLE.' VALUES(\''.$key.'\',\''.sqlite_escape_string(Prado::serialize($value)).'\','.$expire.')';
return @$this->_db->query($sql)!==false;
}
diff --git a/framework/PradoBase.php b/framework/PradoBase.php
index 9470a95a..272c479c 100644
--- a/framework/PradoBase.php
+++ b/framework/PradoBase.php
@@ -199,8 +199,7 @@ class PradoBase
*/
public static function serialize($data)
{
- $arr[0]=$data;
- return serialize($arr);
+ return serialize($data);
}
/**
@@ -212,8 +211,7 @@ class PradoBase
*/
public static function unserialize($str)
{
- $arr=unserialize($str);
- return isset($arr[0])?$arr[0]:null;
+ return unserialize($str);
}
/**