From: Mikael Nordfeldth Date: Sat, 10 Oct 2015 19:40:02 +0000 (+0200) Subject: Using some Managed_DataObject::getByPK calls for consistency X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=18f07a48e8254af78b5a70e2ffaaf171d6a6ca8e;p=quix0rs-gnu-social.git Using some Managed_DataObject::getByPK calls for consistency --- diff --git a/plugins/ActivityModeration/classes/Deleted_notice.php b/plugins/ActivityModeration/classes/Deleted_notice.php index 254d410721..3c6adeb802 100644 --- a/plugins/ActivityModeration/classes/Deleted_notice.php +++ b/plugins/ActivityModeration/classes/Deleted_notice.php @@ -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 diff --git a/plugins/Bookmark/classes/Bookmark.php b/plugins/Bookmark/classes/Bookmark.php index 582eee69f4..b680634ffc 100644 --- a/plugins/Bookmark/classes/Bookmark.php +++ b/plugins/Bookmark/classes/Bookmark.php @@ -27,9 +27,7 @@ * along with this program. If not, see . */ -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())); } /**