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

Attach identities to commits and users to identities

Summary: Ref T12164. Make it easier to work with identity objects by attaching them to commits and attaching users to identities.

Test Plan: Loaded some commits with `->needIdentities(true)` and checked the resulting objects.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12164

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

+74 -3
+24
src/applications/diffusion/query/DiffusionCommitQuery.php
··· 26 26 27 27 private $needCommitData; 28 28 private $needDrafts; 29 + private $needIdentities; 29 30 30 31 private $mustFilterRefs = false; 31 32 private $refRepository; ··· 107 108 108 109 public function needDrafts($need) { 109 110 $this->needDrafts = $need; 111 + return $this; 112 + } 113 + 114 + public function needIdentities($need) { 115 + $this->needIdentities = $need; 110 116 return $this; 111 117 } 112 118 ··· 390 396 foreach ($audit_requests as $audit_request) { 391 397 $audit_request->attachCommit($commit); 392 398 } 399 + } 400 + } 401 + 402 + if ($this->needIdentities) { 403 + $identity_phids = array_merge( 404 + mpull($commits, 'getAuthorIdentityPHID'), 405 + mpull($commits, 'getCommitterIdentityPHID')); 406 + 407 + $data = id(new PhabricatorRepositoryIdentityQuery()) 408 + ->withPHIDs($identity_phids) 409 + ->setViewer($this->getViewer()) 410 + ->execute(); 411 + $data = mpull($data, null, 'getPHID'); 412 + 413 + foreach ($commits as $commit) { 414 + $author_identity = idx($data, $commit->getAuthorIdentityPHID()); 415 + $committer_identity = idx($data, $commit->getCommitterIdentityPHID()); 416 + $commit->attachIdentities($author_identity, $committer_identity); 393 417 } 394 418 } 395 419
+13 -1
src/applications/repository/phid/PhabricatorRepositoryIdentityPHIDType.php
··· 28 28 public function loadHandles( 29 29 PhabricatorHandleQuery $query, 30 30 array $handles, 31 - array $objects) {} 31 + array $objects) { 32 + 33 + foreach ($handles as $phid => $handle) { 34 + $identity = $objects[$phid]; 35 + 36 + $id = $identity->getID(); 37 + $name = $identity->getIdentityNameRaw(); 38 + 39 + $handle->setObjectName(pht('Identity %d', $id)); 40 + $handle->setName($name); 41 + $handle->setURI($identity->getURI()); 42 + } 43 + } 32 44 33 45 }
+4 -2
src/applications/repository/query/PhabricatorRepositoryIdentityQuery.php
··· 131 131 return $identities; 132 132 } 133 133 134 - $users = id(new PhabricatorUser())->loadAllWhere( 135 - 'phid IN (%Ls)', $user_ids); 134 + $users = id(new PhabricatorPeopleQuery()) 135 + ->withPHIDs($user_ids) 136 + ->setViewer($this->getViewer()) 137 + ->execute(); 136 138 $users = mpull($users, null, 'getPHID'); 137 139 138 140 foreach ($identities as $identity) {
+18
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 44 44 private $audits = self::ATTACHABLE; 45 45 private $repository = self::ATTACHABLE; 46 46 private $customFields = self::ATTACHABLE; 47 + private $authorIdentity = self::ATTACHABLE; 48 + private $committerIdentity = self::ATTACHABLE; 49 + 47 50 private $drafts = array(); 48 51 private $auditAuthorityPHIDs = array(); 49 52 ··· 189 192 190 193 public function hasAttachedAudits() { 191 194 return ($this->audits !== self::ATTACHABLE); 195 + } 196 + 197 + public function attachIdentities( 198 + PhabricatorRepositoryIdentity $author, 199 + $committer = null) { 200 + $this->authorIdentity = $author; 201 + $this->committerIdentity = $committer; 202 + } 203 + 204 + public function getAuthorIdentity() { 205 + return $this->assertAttached($this->authorIdentity); 206 + } 207 + 208 + public function getCommiterIdentity() { 209 + return $this->assertAttached($this->committerIdentity); 192 210 } 193 211 194 212 public function loadAndAttachAuditAuthority(
+15
src/applications/repository/storage/PhabricatorRepositoryIdentity.php
··· 14 14 protected $manuallySetUserPHID; 15 15 protected $currentEffectiveUserPHID; 16 16 17 + private $effectiveUser = self::ATTACHABLE; 18 + 19 + public function attachEffectiveUser(PhabricatorUser $user) { 20 + $this->effectiveUser = $user; 21 + return $this; 22 + } 23 + 24 + public function getEffectiveUser() { 25 + return $this->assertAttached($this->effectiveUser); 26 + } 27 + 17 28 protected function getConfiguration() { 18 29 return array( 19 30 self::CONFIG_AUX_PHID => true, ··· 61 72 62 73 public function getURI() { 63 74 return '/diffusion/identity/view/'.$this->getID().'/'; 75 + } 76 + 77 + public function hasEffectiveUser() { 78 + return ($this->currentEffectiveUserPHID != null); 64 79 } 65 80 66 81 public function save() {