From: Evan Prodromou Date: Tue, 23 Aug 2011 04:14:20 +0000 (-0400) Subject: Get primary key for default value in Memcached_DataObject::staticGet() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ce5b44158e691346739739e8ba465453d7af41ea;p=quix0rs-gnu-social.git Get primary key for default value in Memcached_DataObject::staticGet() --- diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index b857ae64b9..51b1556d77 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -34,11 +34,12 @@ class Memcached_DataObject extends Safe_DataObject { if (is_null($v)) { $v = $k; - // XXX: HACK! - $i = new $cls; - $keys = $i->keys(); + $keys = self::pkeyCols($cls); + if (count($keys) > 1) { + // FIXME: maybe call pkeyGet() ourselves? + throw new Exception('Use pkeyGet() for compound primary keys'); + } $k = $keys[0]; - unset($i); } $i = Memcached_DataObject::getcached($cls, $k, $v); if ($i === false) { // false == cache miss