From 3f3ce88c7b5d52142d0e239f2fa83cf14a47d5cc Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 15 Sep 2017 17:46:15 -0700 Subject: [PATCH] (stable) Fix "Author's projects" Herald rules for revisions and diffs Summary: See PHI71. These didn't get properly updated when we wrote Subprojects and Milestones, and should use materialized members, not raw members. Swap the query so projects you are an indirect member of (e.g., milestones you are a member of the parent for, and parent projects you are a member of a subproject of) are included in the result list. Also fix a bad typeahead datasource. Test Plan: - Ran a dry run with the test console, saw project PHIDs for milestones and parent projects in the raw field value. - Tried to set "Author's projects" to a user, no longer could. Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D18619 --- .../DifferentialDiffAuthorProjectsHeraldField.php | 13 +++++++++---- ...ifferentialRevisionAuthorProjectsHeraldField.php | 11 ++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/applications/differential/herald/DifferentialDiffAuthorProjectsHeraldField.php b/src/applications/differential/herald/DifferentialDiffAuthorProjectsHeraldField.php index bec1e2a66c..e484a66ce6 100644 --- a/src/applications/differential/herald/DifferentialDiffAuthorProjectsHeraldField.php +++ b/src/applications/differential/herald/DifferentialDiffAuthorProjectsHeraldField.php @@ -10,9 +10,14 @@ final class DifferentialDiffAuthorProjectsHeraldField } public function getHeraldFieldValue($object) { - return PhabricatorEdgeQuery::loadDestinationPHIDs( - $object->getAuthorPHID(), - PhabricatorProjectMemberOfProjectEdgeType::EDGECONST); + $viewer = PhabricatorUser::getOmnipotentUser(); + + $projects = id(new PhabricatorProjectQuery()) + ->setViewer($viewer) + ->withMemberPHIDs(array($object->getAuthorPHID())) + ->execute(); + + return mpull($projects, 'getPHID'); } protected function getHeraldFieldStandardType() { @@ -20,7 +25,7 @@ final class DifferentialDiffAuthorProjectsHeraldField } protected function getDatasource() { - return new PhabricatorProjectOrUserDatasource(); + return new PhabricatorProjectDatasource(); } } diff --git a/src/applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php b/src/applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php index cb916fcf3d..bd91e810b2 100644 --- a/src/applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php +++ b/src/applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php @@ -10,9 +10,14 @@ final class DifferentialRevisionAuthorProjectsHeraldField } public function getHeraldFieldValue($object) { - return PhabricatorEdgeQuery::loadDestinationPHIDs( - $object->getAuthorPHID(), - PhabricatorProjectMemberOfProjectEdgeType::EDGECONST); + $viewer = PhabricatorUser::getOmnipotentUser(); + + $projects = id(new PhabricatorProjectQuery()) + ->setViewer($viewer) + ->withMemberPHIDs(array($object->getAuthorPHID())) + ->execute(); + + return mpull($projects, 'getPHID'); } protected function getHeraldFieldStandardType() {