From 16a287644848ca8da7a64f8ab71d0ffa969e87bf Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 20 May 2014 06:35:02 -0700 Subject: [PATCH] Fix watcher query to work correctly with no watchers. --- ...habricatorApplicationTransactionEditor.php | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index 6bf0585651..a1e0cc3163 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -1922,22 +1922,23 @@ abstract class PhabricatorApplicationTransactionEditor $query->execute(); $watcher_phids = $query->getDestinationPHIDs(); + if ($watcher_phids) { + // We need to do a visibility check for all the watchers, as + // watching a project is not a guarantee that you can see objects + // associated with it. + $users = id(new PhabricatorPeopleQuery()) + ->setViewer($this->requireActor()) + ->withPHIDs($watcher_phids) + ->execute(); - // We need to do a visibility check for all the watchers, as - // watching a project is not a guarantee that you can see objects - // associated with it. - $users = id(new PhabricatorPeopleQuery()) - ->setViewer($this->requireActor()) - ->withPHIDs($watcher_phids) - ->execute(); - - foreach ($users as $user) { - $can_see = PhabricatorPolicyFilter::hasCapability( - $user, - $object, - PhabricatorPolicyCapability::CAN_VIEW); - if ($can_see) { - $phids[] = $user->getPHID(); + foreach ($users as $user) { + $can_see = PhabricatorPolicyFilter::hasCapability( + $user, + $object, + PhabricatorPolicyCapability::CAN_VIEW); + if ($can_see) { + $phids[] = $user->getPHID(); + } } } }