]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Get primary key for default value in Memcached_DataObject::staticGet()
authorEvan Prodromou <evan@status.net>
Tue, 23 Aug 2011 04:14:20 +0000 (00:14 -0400)
committerEvan Prodromou <evan@status.net>
Tue, 23 Aug 2011 04:14:20 +0000 (00:14 -0400)
classes/Memcached_DataObject.php

index b857ae64b9fdfe79a6a9fdd5417b946963024229..51b1556d77a7144af412e7370c2779bcb1d3c2d9 100644 (file)
@@ -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