]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Syntax and minor fixes
authorMikael Nordfeldth <mmn@hethane.se>
Sat, 10 Oct 2015 20:20:53 +0000 (22:20 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sat, 10 Oct 2015 20:23:24 +0000 (22:23 +0200)
Deleted_notice and Bookmark getByPK assocative array for example.

classes/Managed_DataObject.php
plugins/ActivityModeration/classes/Deleted_notice.php
plugins/Bookmark/BookmarkPlugin.php
plugins/Bookmark/classes/Bookmark.php

index e645b5aec9fa317717f953107c3f3b90cfb27888..8d9bca11b0309fe4cfed7bc1a4d73efb6f81daca 100644 (file)
@@ -334,7 +334,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
         $object = new $classname();
         foreach ($pkey as $col) {
             if (!array_key_exists($col, $vals)) {
-                throw new ServerException("Missing primary key column '{$col}'");
+                throw new ServerException("Missing primary key column '{$col}' for ".get_called_class()." among provided keys: ".implode(',', array_keys($vals)));
             } elseif (is_null($vals[$col])) {
                 throw new ServerException("NULL values not allowed in getByPK for column '{$col}'");
             }
index 3c6adeb80225cdb6235f57d280a33e4960b58ffc..9a0a65c6b21acdebbcd7a102e4d42cca3ada7ffc 100644 (file)
@@ -99,7 +99,7 @@ class Deleted_notice extends Managed_DataObject
     static public function fromStored(Notice $stored)
     {
         $class = get_called_class();
-        return self::getByPK(array('uri', $stored->getUri()));
+        return self::getByPK(array('uri' => $stored->getUri()));
     }
 
     // The one who deleted the notice, not the notice's author
@@ -125,7 +125,7 @@ class Deleted_notice extends Managed_DataObject
     {
         $uri = $this->getUri();
         if (!isset($this->_stored[$uri])) {
-            $this->_stored[$uri] = Notice::getByPK('uri', $uri);
+            $this->_stored[$uri] = Notice::getByPK(array('uri' => $uri));
         }
         return $this->_stored[$uri];
     }
index 6b0c07b6a5e9b8e32975cadf9332119efe513f51..e0f30700ae8c99504ba92029a120fbaa55a2f701 100644 (file)
@@ -479,7 +479,7 @@ class BookmarkPlugin extends MicroAppPlugin
     {
         assert($obj->type == ActivityObject::BOOKMARK);
 
-        $bm = Bookmark::getByPK(array('uri', $obj->id));
+        $bm = Bookmark::getByPK(array('uri' => $obj->id));
 
         $out['displayName'] = $bm->getTitle();
         $out['targetUrl']   = $bm->getUrl();
index e92fd33449453a6d91d53d4bbbc1e81b9c992b23..cdbdf526cae733953ccef6e7e835787c8ea262bf 100644 (file)
@@ -69,9 +69,9 @@ class Bookmark extends Managed_DataObject
                 'description' => array('type' => 'text'),
                 'created' => array('type' => 'datetime', 'not null' => true),
             ),
-            'primary key' => array('id'),
+            'primary key' => array('uri'),
             'unique keys' => array(
-                'bookmark_uri_key' => array('uri'),
+                'bookmark_id_key' => array('id'),
             ),
             'foreign keys' => array(
                 'bookmark_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
@@ -94,8 +94,7 @@ class Bookmark extends Managed_DataObject
      */
     static public function fromStored(Notice $stored)
     {
-        $class = get_called_class();
-        return self::getByPK(array('uri', $stored->getUri()));
+        return self::getByPK(array('uri' => $stored->getUri()));
     }
 
     /**