From ce5b44158e691346739739e8ba465453d7af41ea Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 23 Aug 2011 00:14:20 -0400 Subject: [PATCH] Get primary key for default value in Memcached_DataObject::staticGet() --- classes/Memcached_DataObject.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 -- 2.39.5