]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Using some Managed_DataObject::getByPK calls for consistency
authorMikael Nordfeldth <mmn@hethane.se>
Sat, 10 Oct 2015 19:40:02 +0000 (21:40 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sat, 10 Oct 2015 19:40:02 +0000 (21:40 +0200)
plugins/ActivityModeration/classes/Deleted_notice.php
plugins/Bookmark/classes/Bookmark.php

index 254d4107211a66b52138fa72830f8f1ffab40b8f..3c6adeb80225cdb6235f57d280a33e4960b58ffc 100644 (file)
@@ -99,12 +99,7 @@ class Deleted_notice extends Managed_DataObject
     static public function fromStored(Notice $stored)
     {
         $class = get_called_class();
-        $object = new $class;
-        $object->uri = $stored->getUri();   // Lookup by delete activity's URI! (that's what is _stored_ in our db!)
-        if (!$object->find(true)) {
-            throw new NoResultException($object);
-        }
-        return $object;
+        return self::getByPK(array('uri', $stored->getUri()));
     }
 
     // The one who deleted the notice, not the notice's author
index 582eee69f44e1246146aa78c2f13e6f0bd62cd20..b680634ffc82ae8ad995b86bff099f3ba63394d0 100644 (file)
@@ -27,9 +27,7 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * For storing the fact that a notice is a bookmark
@@ -77,6 +75,7 @@ class Bookmark extends Managed_DataObject
             ),
             'foreign keys' => array(
                 'bookmark_profile_id_fkey' => array('profile', array('profile_id' => 'id'))
+                'bookmark_uri_fkey' => array('notice', array('uri' => 'uri'))
             ),
             'indexes' => array('bookmark_created_idx' => array('created'),
                             'bookmark_url_idx' => array('url'),
@@ -88,13 +87,15 @@ class Bookmark extends Managed_DataObject
     /**
      * Get a bookmark based on a notice
      *
-     * @param Notice $notice Notice to check for
+     * @param   Notice              $stored Notice activity which represents the Bookmark
      *
-     * @return Bookmark found bookmark or null
+     * @return  Bookmark            The found bookmark object.
+     * @throws  NoResultException   When you don't find it after all.
      */
-    static function getByNotice($notice)
+    static public function fromStored(Notice $stored)
     {
-        return self::getKV('uri', $notice->uri);
+        $class = get_called_class();
+        return self::getByPK(array('uri', $stored->getUri()));
     }
 
     /**