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

Internally, align commit processing tasks around PHIDs, not IDs

Summary: Ref T13591. This is a minor consistency change to use PHIDs instead of IDs in the commit import processing pipeline. PHIDs are generally more powerful in more contexts and it would be unusual for a modern worker to use an ID here.

Test Plan:
- Made the "accept either ID or PHID" part of the change only.
- Pushed a commit, parsed and reparsed it step by step (this tests that "commitID" tasks can still process normally).
- Made the "write PHIDs" part of the change.
- Pushed a commit, parsed and reparsed it step by step.
- Looked at the task row in the database, saw PHID data.

Maniphest Tasks: T13591

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

+36 -18
-1
src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
··· 682 682 683 683 $this->queueCommitImportTask( 684 684 $repository, 685 - $commit->getID(), 686 685 $commit->getPHID(), 687 686 $task_priority, 688 687 $via = 'discovery');
+2 -3
src/applications/repository/engine/PhabricatorRepositoryEngine.php
··· 85 85 86 86 final protected function queueCommitImportTask( 87 87 PhabricatorRepository $repository, 88 - $commit_id, 89 88 $commit_phid, 90 89 $task_priority, 91 - $via = null) { 90 + $via) { 92 91 93 92 $vcs = $repository->getVersionControlSystem(); 94 93 switch ($vcs) { ··· 109 108 } 110 109 111 110 $data = array( 112 - 'commitID' => $commit_id, 111 + 'commitPHID' => $commit_phid, 113 112 ); 114 113 115 114 if ($via !== null) {
-1
src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
··· 597 597 598 598 $this->queueCommitImportTask( 599 599 $repository, 600 - $row['id'], 601 600 $row['phid'], 602 601 $task_priority, 603 602 $via = 'ref');
+1 -1
src/applications/repository/management/PhabricatorRepositoryManagementReparseWorkflow.php
··· 247 247 // all the requested steps explicitly. 248 248 249 249 $spec = array( 250 - 'commitID' => $commit->getID(), 250 + 'commitPHID' => $commit->getPHID(), 251 251 'only' => !$importing, 252 252 'via' => 'reparse', 253 253 );
+33 -12
src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php
··· 11 11 return $this->commit; 12 12 } 13 13 14 - $commit_id = idx($this->getTaskData(), 'commitID'); 15 - if (!$commit_id) { 14 + $viewer = $this->getViewer(); 15 + $task_data = $this->getTaskData(); 16 + 17 + $commit_query = id(new DiffusionCommitQuery()) 18 + ->setViewer($viewer); 19 + 20 + $commit_phid = idx($task_data, 'commitPHID'); 21 + 22 + // TODO: See T13591. This supports execution of legacy tasks and can 23 + // eventually be removed. Newer tasks use "commitPHID" instead of 24 + // "commitID". 25 + if (!$commit_phid) { 26 + $commit_id = idx($task_data, 'commitID'); 27 + if ($commit_id) { 28 + $legacy_commit = id(clone $commit_query) 29 + ->withIDs(array($commit_id)) 30 + ->executeOne(); 31 + if ($legacy_commit) { 32 + $commit_phid = $legacy_commit->getPHID(); 33 + } 34 + } 35 + } 36 + 37 + if (!$commit_phid) { 16 38 throw new PhabricatorWorkerPermanentFailureException( 17 - pht('No "%s" in task data.', 'commitID')); 39 + pht('Task data has no "commitPHID".')); 18 40 } 19 41 20 - $commit = id(new DiffusionCommitQuery()) 21 - ->setViewer(PhabricatorUser::getOmnipotentUser()) 22 - ->withIDs(array($commit_id)) 42 + $commit = id(clone $commit_query) 43 + ->withPHIDs(array($commit_phid)) 23 44 ->executeOne(); 24 45 if (!$commit) { 25 46 throw new PhabricatorWorkerPermanentFailureException( 26 - pht('Commit "%s" does not exist.', $commit_id)); 47 + pht('Commit "%s" does not exist.', $commit_phid)); 27 48 } 28 49 29 50 if ($commit->isUnreachable()) { 30 51 throw new PhabricatorWorkerPermanentFailureException( 31 52 pht( 32 - 'Commit "%s" (with internal ID "%s") is no longer reachable from '. 33 - 'any branch, tag, or ref in this repository, so it will not be '. 53 + 'Commit "%s" (with PHID "%s") is no longer reachable from any '. 54 + 'branch, tag, or ref in this repository, so it will not be '. 34 55 'imported. This usually means that the branch the commit was on '. 35 56 'was deleted or overwritten.', 36 57 $commit->getMonogram(), 37 - $commit_id)); 58 + $commit_phid)); 38 59 } 39 60 40 61 $this->commit = $commit; ··· 64 85 $repository = $commit->getRepository(); 65 86 66 87 $data = array( 67 - 'commitID' => $commit->getID(), 88 + 'commitPHID' => $commit->getPHID(), 68 89 ); 69 90 70 91 $task_data = $this->getTaskData(); ··· 144 165 145 166 $commit = id(new DiffusionCommitQuery()) 146 167 ->setViewer($viewer) 147 - ->withIDs(array(idx($this->getTaskData(), 'commitID'))) 168 + ->withPHIDs(array(idx($this->getTaskData(), 'commitPHID'))) 148 169 ->executeOne(); 149 170 if (!$commit) { 150 171 return $suffix;