@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.

Consider packages when calculating Differential authority

Summary:
Ref T10939. This has no effect yet since packages can not actually become reviewers, I'm just inching toward support.

- When searching for "responsible users", include revisions that need review by packages you have authority over.
- When calculating review authority, include authority over packages you are a member of (these currently never exist).

Test Plan:
This isn't reachable so I just `var_dump()`'d stuff and looked at the generated queries, which appeared correct/reasonable.

I'll vet this more thoroughly once packages can actually become reviewers.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10939

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

+44 -10
+44 -10
src/applications/differential/query/DifferentialRevisionQuery.php
··· 531 531 $basic_authors = $this->authors; 532 532 $basic_reviewers = $this->reviewers; 533 533 534 + $authority_phids = $this->responsibles; 535 + 534 536 $authority_projects = id(new PhabricatorProjectQuery()) 535 537 ->setViewer($this->getViewer()) 536 538 ->withMemberPHIDs($this->responsibles) 537 539 ->execute(); 538 - $authority_phids = mpull($authority_projects, 'getPHID'); 540 + foreach ($authority_projects as $project) { 541 + $authority_phids[] = $project->getPHID(); 542 + } 543 + 544 + // NOTE: We're querying by explicit owners to make this a little faster, 545 + // since we've already expanded project membership so we don't need to 546 + // have the PackageQuery do it again. 547 + $authority_packages = id(new PhabricatorOwnersPackageQuery()) 548 + ->setViewer($this->getViewer()) 549 + ->withOwnerPHIDs($authority_phids) 550 + ->execute(); 551 + foreach ($authority_packages as $package) { 552 + $authority_phids[] = $package->getPHID(); 553 + } 539 554 540 555 try { 541 556 // Build the query where the responsible users are authors. ··· 548 563 $this->authors = $basic_authors; 549 564 $this->reviewers = array_merge( 550 565 $basic_reviewers, 551 - $this->responsibles, 552 566 $authority_phids); 553 567 $selects[] = $this->buildSelectStatement($conn_r); 554 568 ··· 1105 1119 $revision_map = mpull($revisions, null, 'getPHID'); 1106 1120 $viewer_phid = $this->getViewer()->getPHID(); 1107 1121 1108 - // Find all the project reviewers which the user may have authority over. 1122 + // Find all the project/package reviewers which the user may have authority 1123 + // over. 1109 1124 $project_phids = array(); 1125 + $package_phids = array(); 1110 1126 $project_type = PhabricatorProjectProjectPHIDType::TYPECONST; 1127 + $package_type = PhabricatorOwnersPackagePHIDType::TYPECONST; 1128 + 1111 1129 $edge_type = DifferentialRevisionHasReviewerEdgeType::EDGECONST; 1112 1130 foreach ($edges as $src => $types) { 1113 1131 if (!$allow_self) { ··· 1121 1139 } 1122 1140 $edge_data = idx($types, $edge_type, array()); 1123 1141 foreach ($edge_data as $dst => $data) { 1124 - if (phid_get_type($dst) == $project_type) { 1142 + $phid_type = phid_get_type($dst); 1143 + if ($phid_type == $project_type) { 1125 1144 $project_phids[] = $dst; 1126 1145 } 1146 + if ($phid_type == $package_type) { 1147 + $package_phids[] = $dst; 1148 + } 1127 1149 } 1128 1150 } 1129 1151 1130 - // Now, figure out which of these projects the viewer is actually a 1131 - // member of. 1152 + // The viewer has authority over themselves. 1153 + $user_authority = array_fuse(array($viewer_phid)); 1154 + 1155 + // And over any projects they are a member of. 1132 1156 $project_authority = array(); 1133 1157 if ($project_phids) { 1134 1158 $project_authority = id(new PhabricatorProjectQuery()) ··· 1137 1161 ->withMemberPHIDs(array($viewer_phid)) 1138 1162 ->execute(); 1139 1163 $project_authority = mpull($project_authority, 'getPHID'); 1164 + $project_authority = array_fuse($project_authority); 1140 1165 } 1141 1166 1142 - // Finally, the viewer has authority over themselves. 1143 - return array( 1144 - $viewer_phid => true, 1145 - ) + array_fuse($project_authority); 1167 + // And over any packages they own. 1168 + $package_authority = array(); 1169 + if ($package_phids) { 1170 + $package_authority = id(new PhabricatorOwnersPackageQuery()) 1171 + ->setViewer($this->getViewer()) 1172 + ->withPHIDs($package_phids) 1173 + ->withAuthorityPHIDs(array($viewer_phid)) 1174 + ->execute(); 1175 + $package_authority = mpull($package_authority, 'getPHID'); 1176 + $package_authority = array_fuse($package_authority); 1177 + } 1178 + 1179 + return $user_authority + $project_authority + $package_authority; 1146 1180 } 1147 1181 1148 1182 public function getQueryApplicationClass() {