Rearrange Memcached_DataObject::staticGet() to avoid "only variables can be passed by reference" warnings when DB lookup fails and we return false.

(We need to keep it returning a reference because the extlib parent class is stuck in PHP 4-land and uses references everywhere, including this function's return value. Yuck!)

Also changed pkeyGet to drop the reference, since it doesn't have an upstream equivalent.
This commit is contained in:
Brion Vibber 2010-01-06 13:23:39 -08:00
parent 6f5b765c97
commit 85554d0840

View File

@ -90,17 +90,16 @@ class Memcached_DataObject extends DB_DataObject
unset($i);
}
$i = Memcached_DataObject::getcached($cls, $k, $v);
if ($i !== false) { // false == cache miss
return $i;
} else {
if ($i === false) { // false == cache miss
$i = DB_DataObject::factory($cls);
if (empty($i)) {
return false;
$i = false;
return $i;
}
$result = $i->get($k, $v);
if ($result) {
// Hit!
$i->encache();
return $i;
} else {
// save the fact that no such row exists
$c = self::memcache();
@ -108,12 +107,16 @@ class Memcached_DataObject extends DB_DataObject
$ck = self::cachekey($cls, $k, $v);
$c->set($ck, null);
}
return false;
$i = false;
}
}
return $i;
}
function &pkeyGet($cls, $kv)
/**
* @fixme Should this return false on lookup fail to match staticGet?
*/
function pkeyGet($cls, $kv)
{
$i = Memcached_DataObject::multicache($cls, $kv);
if ($i !== false) { // false == cache miss