From: Mikael Nordfeldth Date: Tue, 17 Feb 2015 16:15:47 +0000 (+0100) Subject: Subscription class gets exception throwing getSubscription function X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=61aa71ed34d944d6c4005fdeb33c2128d51eed9d;p=quix0rs-gnu-social.git Subscription class gets exception throwing getSubscription function --- diff --git a/classes/Subscription.php b/classes/Subscription.php index 4d7eb524dc..cd9ae3cce5 100644 --- a/classes/Subscription.php +++ b/classes/Subscription.php @@ -232,9 +232,25 @@ class Subscription extends Managed_DataObject static function exists(Profile $subscriber, Profile $other) { - $sub = Subscription::pkeyGet(array('subscriber' => $subscriber->id, - 'subscribed' => $other->id)); - return ($sub instanceof Subscription); + try { + $sub = self::getSubscription($subscriber, $other); + } catch (NoResultException $e) { + return false; + } + + return true; + } + + static function getSubscription(Profile $subscriber, Profile $other) + { + // This is essentially a pkeyGet but we have an object to return in NoResultException + $sub = new Subscription(); + $sub->subscriber = $subscriber->id; + $sub->subscribed = $other->id; + if (!$sub->find(true)) { + throw new NoResultException($sub); + } + return $sub; } function asActivity()