From 5a9d70707b9e16169b8a298135b36dd133e2ae38 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 16 Feb 2015 11:17:51 -0800 Subject: [PATCH] Fix bad Phortune Subscriptions query Summary: Fixes T7285. If the user tries to view a subscription they don't have permission to view, we may filter all the subscriptions out, then still try to load related data. This can fatal because it's invalid. Instead, bail if we filtered everything. Test Plan: Subscritption detail page of another user's subscription is now 404 instead of fatal. Reviewers: btrahan, chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T7285 Differential Revision: https://secure.phabricator.com/D11780 --- .../phortune/query/PhortuneSubscriptionQuery.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/applications/phortune/query/PhortuneSubscriptionQuery.php b/src/applications/phortune/query/PhortuneSubscriptionQuery.php index b789030dca..ba6d7acc73 100644 --- a/src/applications/phortune/query/PhortuneSubscriptionQuery.php +++ b/src/applications/phortune/query/PhortuneSubscriptionQuery.php @@ -72,6 +72,10 @@ final class PhortuneSubscriptionQuery $subscription->attachAccount($account); } + if (!$subscriptions) { + return $subscriptions; + } + $merchants = id(new PhortuneMerchantQuery()) ->setViewer($this->getViewer()) ->withPHIDs(mpull($subscriptions, 'getMerchantPHID')) @@ -87,6 +91,10 @@ final class PhortuneSubscriptionQuery $subscription->attachMerchant($merchant); } + if (!$subscriptions) { + return $subscriptions; + } + $implementations = array(); $subscription_map = mgroup($subscriptions, 'getSubscriptionClass'); @@ -109,6 +117,10 @@ final class PhortuneSubscriptionQuery $subscription->attachImplementation($implementation); } + if (!$subscriptions) { + return $subscriptions; + } + if ($this->needTriggers) { $trigger_phids = mpull($subscriptions, 'getTriggerPHID'); $triggers = id(new PhabricatorWorkerTriggerQuery())