@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Draw project PHIDs from repositories when evaluating Herald object rules for commits

Summary:
Fixes T12097. In D16413, I simplified this code but caused us to load the //commit's// projects instead of the //repository's// projects, which is incorrect.

Normally, commits don't have any project tags when Herald evaluates, so using the commit's projects is generally meaningless.

Test Plan:
- Tagged a repository with `#X`.
- Created a Herald object rule for commits with `#X` as the object ("Always ... do nothing.")
- Ran a commit from the repository.
- Before patch: rule failed to evaluate.
- After patch: rule evaluated and passed.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12097

Differential Revision: https://secure.phabricator.com/D17179

+20 -6
+20 -6
src/applications/diffusion/herald/HeraldCommitAdapter.php
··· 104 104 public function getTriggerObjectPHIDs() { 105 105 $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; 106 106 107 - return array_merge( 108 - array( 109 - $this->getRepository()->getPHID(), 110 - $this->getPHID(), 111 - ), 112 - $this->loadEdgePHIDs($project_type)); 107 + $repository_phid = $this->getRepository()->getPHID(); 108 + $commit_phid = $this->getObject()->getPHID(); 109 + 110 + $phids = array(); 111 + $phids[] = $commit_phid; 112 + $phids[] = $repository_phid; 113 + 114 + // NOTE: This is projects for the repository, not for the commit. When 115 + // Herald evalutes, commits normally can not have any project tags yet. 116 + $repository_project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( 117 + $repository_phid, 118 + $project_type); 119 + foreach ($repository_project_phids as $phid) { 120 + $phids[] = $phid; 121 + } 122 + 123 + $phids = array_unique($phids); 124 + $phids = array_values($phids); 125 + 126 + return $phids; 113 127 } 114 128 115 129 public function explainValidTriggerObjects() {