diff --git a/src/applications/herald/adapter/HeraldCommitAdapter.php b/src/applications/herald/adapter/HeraldCommitAdapter.php index 36e5d87375..49abc2430f 100644 --- a/src/applications/herald/adapter/HeraldCommitAdapter.php +++ b/src/applications/herald/adapter/HeraldCommitAdapter.php @@ -221,10 +221,20 @@ final class HeraldCommitAdapter extends HeraldAdapter { $data = $this->commitData; $revision_id = $data->getCommitDetail('differential.revisionID'); if ($revision_id) { - // TODO: (T603) Herald policy stuff. - $revision = id(new DifferentialRevision())->load($revision_id); + // NOTE: The Herald rule owner might not actually have access to + // the revision, and can control which revision a commit is + // associated with by putting text in the commit message. However, + // the rules they can write against revisions don't actually expose + // anything interesting, so it seems reasonable to load unconditionally + // here. + + $revision = id(new DifferentialRevisionQuery()) + ->withIDs(array($revision_id)) + ->setViewer(PhabricatorUser::getOmnipotentUser()) + ->needRelationships(true) + ->needReviewerStatus(true) + ->executeOne(); if ($revision) { - $revision->loadRelationships(); $this->affectedRevision = $revision; } } diff --git a/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php b/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php index 7776330d1a..16d29ff1d8 100644 --- a/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php +++ b/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php @@ -62,10 +62,16 @@ final class HeraldDifferentialRevisionAdapter extends HeraldAdapter { public static function newLegacyAdapter( DifferentialRevision $revision, DifferentialDiff $diff) { - $object = new HeraldDifferentialRevisionAdapter(); - $revision->loadRelationships(); + // Reload the revision to pick up relationship information. + $revision = id(new DifferentialRevisionQuery()) + ->withIDs(array($revision->getID())) + ->setViewer(PhabricatorUser::getOmnipotentUser()) + ->needRelationships(true) + ->needReviewerStatus(true) + ->executeOne(); + $object->revision = $revision; $object->diff = $diff;