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

Remove some ad-hoc handle loads from Releeph

Summary:
Ref T3551. Releeph does a bunch of old-school on-object data loading; start cleaning that up.

This doesn't change anything, just makes the code more modern/consistent.

Test Plan: Edited a request; called `releephwork.nextrequest`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T3551

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

+38 -82
+8 -10
src/applications/releeph/conduit/ConduitAPI_releeph_request_Method.php
··· 28 28 29 29 protected function execute(ConduitAPIRequest $request) { 30 30 $user = $request->getUser(); 31 + 32 + $viewer_handle = id(new PhabricatorHandleQuery()) 33 + ->setViewer($user) 34 + ->withPHIDs(array($user->getPHID())) 35 + ->executeOne(); 36 + 31 37 $branch_phid = $request->getValue('branchPHID'); 32 38 $releeph_branch = id(new ReleephBranch()) 33 39 ->loadOneWhere('phid = %s', $branch_phid); ··· 131 137 $editor->applyTransactions($releeph_request, $xactions); 132 138 } 133 139 134 - $releeph_branch->populateReleephRequestHandles( 135 - $user, 136 - array($releeph_request)); 137 - $rq_handles = $releeph_request->getHandles(); 138 - $requestor_phid = $releeph_request->getRequestUserPHID(); 139 - $requestor = $rq_handles[$requestor_phid]->getName(); 140 - 141 - $url = PhabricatorEnv::getProductionURI('/RQ'.$releeph_request->getID()); 142 - 140 + $url = PhabricatorEnv::getProductionURI('/Y'.$releeph_request->getID()); 143 141 $results[$thing] = array( 144 142 'thing' => $thing, 145 143 'branch' => $releeph_branch->getDisplayNameWithDetail(), ··· 147 145 'commitID' => $commit->getCommitIdentifier(), 148 146 'url' => $url, 149 147 'requestID' => $releeph_request->getID(), 150 - 'requestor' => $requestor, 148 + 'requestor' => $viewer_handle->getName(), 151 149 'requestTime' => $releeph_request->getDateCreated(), 152 150 'existing' => $existing_releeph_request !== null, 153 151 );
+8 -3
src/applications/releeph/conduit/work/ConduitAPI_releephwork_nextrequest_Method.php
··· 18 18 19 19 public function defineParamTypes() { 20 20 return array( 21 - 'branchPHID' => 'required int', 22 - 'seen' => 'required list<string, bool>', 21 + 'branchPHID' => 'required phid', 22 + 'seen' => 'required map<string, bool>', 23 23 ); 24 24 } 25 25 ··· 35 35 } 36 36 37 37 protected function execute(ConduitAPIRequest $request) { 38 + $viewer = $request->getUser(); 38 39 $seen = $request->getValue('seen'); 39 40 40 41 $branch = id(new ReleephBranch()) ··· 45 46 $needs_pick = array(); 46 47 $needs_revert = array(); 47 48 48 - $releeph_requests = $branch->loadReleephRequests($request->getUser()); 49 + // Load every request ever made for this branch...?!!! 50 + $releeph_requests = id(new ReleephRequestQuery()) 51 + ->setViewer($viewer) 52 + ->withBranchIDs(array($branch->getID())) 53 + ->execute(); 49 54 50 55 foreach ($releeph_requests as $candidate) { 51 56 $phid = $candidate->getPHID();
+13 -2
src/applications/releeph/controller/request/ReleephRequestEditController.php
··· 178 178 } 179 179 } 180 180 181 - $branch->populateReleephRequestHandles($viewer, array($pull)); 182 - $handles = $pull->getHandles(); 181 + $handle_phids = array( 182 + $pull->getRequestUserPHID(), 183 + $pull->getRequestCommitPHID(), 184 + ); 185 + $handle_phids = array_filter($handle_phids); 186 + if ($handle_phids) { 187 + $handles = id(new PhabricatorHandleQuery()) 188 + ->setViewer($viewer) 189 + ->withPHIDs($handle_phids) 190 + ->execute(); 191 + } else { 192 + $handles = array(); 193 + } 183 194 184 195 $age_string = ''; 185 196 if ($is_edit) {
+9 -15
src/applications/releeph/field/specification/ReleephBranchCommitFieldSpecification.php
··· 11 11 return 'Commit'; 12 12 } 13 13 14 - public function renderPropertyViewValue(array $handles) { 15 - $rr = $this->getReleephRequest(); 16 - if (!$rr->getInBranch()) { 17 - return null; 14 + public function getRequiredHandlePHIDsForPropertyView() { 15 + $pull = $this->getReleephRequest(); 16 + 17 + if ($pull->getCommitPHID()) { 18 + return array($pull->getCommitPHID()); 18 19 } 19 20 20 - $c_phid = $rr->getCommitPHID(); 21 - $c_id = $rr->getCommitIdentifier(); 21 + return array(); 22 + } 22 23 23 - if ($c_phid) { 24 - $handles = $rr->getHandles(); 25 - $val = $handles[$c_phid]->renderLink(); 26 - } else if ($c_id) { 27 - $val = $c_id; 28 - } else { 29 - $val = '???'; 30 - } 31 - return $val; 24 + public function renderPropertyViewValue(array $handles) { 25 + return $this->renderHandleList($handles); 32 26 } 33 27 34 28 }
-40
src/applications/releeph/storage/ReleephBranch.php
··· 109 109 'getReleephProjectID'); 110 110 } 111 111 112 - private function loadReleephRequestHandles(PhabricatorUser $user, $reqs) { 113 - $phids_to_phetch = array(); 114 - foreach ($reqs as $rr) { 115 - $phids_to_phetch[] = $rr->getRequestCommitPHID(); 116 - $phids_to_phetch[] = $rr->getRequestUserPHID(); 117 - $phids_to_phetch[] = $rr->getCommitPHID(); 118 - 119 - $intents = $rr->getUserIntents(); 120 - if ($intents) { 121 - foreach ($intents as $user_phid => $intent) { 122 - $phids_to_phetch[] = $user_phid; 123 - } 124 - } 125 - 126 - $request_commit = $rr->loadPhabricatorRepositoryCommit(); 127 - if ($request_commit) { 128 - $phids_to_phetch[] = $request_commit->getAuthorPHID(); 129 - $phids_to_phetch[] = $rr->loadRequestCommitDiffPHID(); 130 - } 131 - } 132 - $handles = id(new PhabricatorHandleQuery()) 133 - ->setViewer($user) 134 - ->withPHIDs($phids_to_phetch) 135 - ->execute(); 136 - return $handles; 137 - } 138 - 139 - public function populateReleephRequestHandles(PhabricatorUser $user, $reqs) { 140 - $handles = $this->loadReleephRequestHandles($user, $reqs); 141 - foreach ($reqs as $req) { 142 - $req->setHandles($handles); 143 - } 144 - } 145 - 146 - public function loadReleephRequests(PhabricatorUser $user) { 147 - $reqs = $this->loadRelatives(new ReleephRequest(), 'branchID'); 148 - $this->populateReleephRequestHandles($user, $reqs); 149 - return $reqs; 150 - } 151 - 152 112 public function isActive() { 153 113 return $this->getIsActive(); 154 114 }
-12
src/applications/releeph/storage/ReleephRequest.php
··· 20 20 protected $commitIdentifier; 21 21 protected $commitPHID; 22 22 23 - // Pre-populated handles that we'll bulk load in ReleephBranch 24 - private $handles = self::ATTACHABLE; 25 - 26 23 private $customFields = self::ATTACHABLE; 27 24 private $branch = self::ATTACHABLE; 28 - 29 25 30 26 31 27 /* -( Constants and helper methods )--------------------------------------- */ ··· 160 156 161 157 /* -( Helpful accessors )--------------------------------------------------- */ 162 158 163 - public function setHandles($handles) { 164 - $this->handles = $handles; 165 - return $this; 166 - } 167 - 168 - public function getHandles() { 169 - return $this->assertAttached($this->handles); 170 - } 171 159 172 160 public function getDetail($key, $default = null) { 173 161 return idx($this->getDetails(), $key, $default);