@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

Build "DiffusionCommitRef" objects from "internal.commit.search", not "diffusion.querycommits", in the message parser worker

Summary: Ref T13552. Swap the call we're using to build "CommitRef" objects here to the recently-introduced "internal.commit.search" method.

Test Plan: Used "bin/repository reparse --message ..." to reparse commits, added "var_dump()" to inspect results. Saw sensible CommitRef and CommitData objects get built.

Maniphest Tasks: T13552

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

+76 -32
+3 -9
src/applications/diffusion/query/DiffusionQuery.php
··· 73 73 74 74 $params = $params + $core_params; 75 75 76 - $client = $repository->newConduitClient( 76 + $future = $repository->newConduitFuture( 77 77 $user, 78 + $method, 79 + $params, 78 80 $drequest->getIsClusterRequest()); 79 - if (!$client) { 80 - $result = id(new ConduitCall($method, $params)) 81 - ->setUser($user) 82 - ->execute(); 83 - $future = new ImmediateFuture($result); 84 - } else { 85 - $future = $client->callMethod($method, $params); 86 - } 87 81 88 82 if (!$return_future) { 89 83 return $future->resolve();
+22
src/applications/repository/storage/PhabricatorRepository.php
··· 2258 2258 return $client; 2259 2259 } 2260 2260 2261 + public function newConduitFuture( 2262 + PhabricatorUser $viewer, 2263 + $method, 2264 + array $params, 2265 + $never_proxy = false) { 2266 + 2267 + $client = $this->newConduitClient( 2268 + $viewer, 2269 + $never_proxy); 2270 + 2271 + if (!$client) { 2272 + $result = id(new ConduitCall($method, $params)) 2273 + ->setUser($viewer) 2274 + ->execute(); 2275 + $future = new ImmediateFuture($result); 2276 + } else { 2277 + $future = $client->callMethod($method, $params); 2278 + } 2279 + 2280 + return $future; 2281 + } 2282 + 2261 2283 public function getPassthroughEnvironmentalVariables() { 2262 2284 $env = $_ENV; 2263 2285
+44
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 523 523 return $data->getCommitDetail('committer'); 524 524 } 525 525 526 + public function newCommitRef(PhabricatorUser $viewer) { 527 + $repository = $this->getRepository(); 528 + 529 + $future = $repository->newConduitFuture( 530 + $viewer, 531 + 'internal.commit.search', 532 + array( 533 + 'constraints' => array( 534 + 'repositoryPHIDs' => array($repository->getPHID()), 535 + 'phids' => array($this->getPHID()), 536 + ), 537 + )); 538 + $result = $future->resolve(); 539 + 540 + $commit_display = $this->getMonogram(); 541 + 542 + if (empty($result['data'])) { 543 + throw new Exception( 544 + pht( 545 + 'Unable to retrieve details for commit "%s"!', 546 + $commit_display)); 547 + } 548 + 549 + if (count($result['data']) !== 1) { 550 + throw new Exception( 551 + pht( 552 + 'Got too many results (%s) for commit "%s", expected %s.', 553 + phutil_count($result['data']), 554 + $commit_display, 555 + 1)); 556 + } 557 + 558 + $record = head($result['data']); 559 + $ref_record = idxv($record, array('fields', 'ref')); 560 + 561 + if (!$ref_record) { 562 + throw new Exception( 563 + pht( 564 + 'Unable to retrieve CommitRef record for commit "%s".', 565 + $commit_display)); 566 + } 567 + 568 + return DiffusionCommitRef::newFromDictionary($ref_record); 569 + } 526 570 527 571 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 528 572
+5
src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php
··· 124 124 125 125 return array($link, $suffix); 126 126 } 127 + 128 + final public function getViewer() { 129 + return PhabricatorUser::getOmnipotentUser(); 130 + } 131 + 127 132 }
+2 -23
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 14 14 PhabricatorRepositoryCommit $commit) { 15 15 16 16 if (!$this->shouldSkipImportStep()) { 17 - $viewer = PhabricatorUser::getOmnipotentUser(); 17 + $viewer = $this->getViewer(); 18 18 19 - $refs_raw = DiffusionQuery::callConduitWithDiffusionRequest( 20 - $viewer, 21 - DiffusionRequest::newFromDictionary( 22 - array( 23 - 'repository' => $repository, 24 - 'user' => $viewer, 25 - )), 26 - 'diffusion.querycommits', 27 - array( 28 - 'repositoryPHID' => $repository->getPHID(), 29 - 'phids' => array($commit->getPHID()), 30 - 'bypassCache' => true, 31 - 'needMessages' => true, 32 - )); 19 + $ref = $commit->newCommitRef($viewer); 33 20 34 - if (empty($refs_raw['data'])) { 35 - throw new Exception( 36 - pht( 37 - 'Unable to retrieve details for commit "%s"!', 38 - $commit->getPHID())); 39 - } 40 - 41 - $ref = DiffusionCommitRef::newFromConduitResult(head($refs_raw['data'])); 42 21 $this->updateCommitData($ref); 43 22 } 44 23