@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 loadReleephBranch and loadReleephProject from ReleephRequest

Summary: Ref T3551. Ref T3549. Mostly unnecessary with modern calls.

Test Plan:
- Called `releeph.queryrequests`.
- Called `releeph.request`.
- Called `releephwork.getbranchcommitmessage`.
- Called `releephwork.getcommitmessage`.
- Called `releephwork.nextrequest`.
- Viewed and edited branches and requests.
- Made a comment on a request.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T3549, T3551

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

+60 -71
+2 -4
src/applications/releeph/conduit/ConduitAPI_releeph_queryrequests_Method.php
··· 45 45 $releephRequests = $query->execute(); 46 46 47 47 foreach ($releephRequests as $releephRequest) { 48 - $branch = $releephRequest->loadReleephBranch(); 49 - if (!$branch) { 50 - continue; 51 - } 48 + $branch = $releephRequest->getBranch(); 49 + 52 50 $request_commit_phid = $releephRequest->getRequestCommitPHID(); 53 51 $revisionPHID = 54 52 $query->getRevisionPHID($request_commit_phid);
+6 -4
src/applications/releeph/conduit/ConduitAPI_releeph_request_Method.php
··· 10 10 public function defineParamTypes() { 11 11 return array( 12 12 'branchPHID' => 'required string', 13 - 'things' => 'required string', 13 + 'things' => 'required list<string>', 14 14 'fields' => 'dict<string, string>', 15 15 ); 16 16 } ··· 35 35 ->executeOne(); 36 36 37 37 $branch_phid = $request->getValue('branchPHID'); 38 - $releeph_branch = id(new ReleephBranch()) 39 - ->loadOneWhere('phid = %s', $branch_phid); 38 + $releeph_branch = id(new ReleephBranchQuery()) 39 + ->setViewer($user) 40 + ->withPHIDs(array($branch_phid)) 41 + ->executeOne(); 40 42 41 43 if (!$releeph_branch) { 42 44 throw id(new ConduitException("ERR_BRANCH"))->setErrorDescription( 43 45 "No ReleephBranch found with PHID {$branch_phid}!"); 44 46 } 45 47 46 - $releeph_project = $releeph_branch->loadReleephProject(); 48 + $releeph_project = $releeph_branch->getProduct(); 47 49 48 50 // Find the requested commit identifiers 49 51 $requested_commits = array();
+7 -3
src/applications/releeph/conduit/work/ConduitAPI_releephwork_getbranchcommitmessage_Method.php
··· 26 26 } 27 27 28 28 protected function execute(ConduitAPIRequest $request) { 29 - $branch = id(new ReleephBranch()) 30 - ->loadOneWhere('phid = %s', $request->getValue('branchPHID')); 29 + $viewer = $request->getUser(); 31 30 32 - $project = $branch->loadReleephProject(); 31 + $branch = id(new ReleephBranchQuery()) 32 + ->setViewer($viewer) 33 + ->withPHIDs(array($request->getValue('branchPHID'))) 34 + ->executeOne(); 35 + 36 + $project = $branch->getProduct(); 33 37 34 38 $creator_phid = $branch->getCreatedByUserPHID(); 35 39 $cut_phid = $branch->getCutPointCommitPHID();
+8 -4
src/applications/releeph/conduit/work/ConduitAPI_releephwork_getcommitmessage_Method.php
··· 29 29 } 30 30 31 31 protected function execute(ConduitAPIRequest $request) { 32 - $releeph_request = id(new ReleephRequest()) 33 - ->loadOneWhere('phid = %s', $request->getValue('requestPHID')); 32 + $viewer = $request->getUser(); 33 + 34 + $releeph_request = id(new ReleephRequestQuery()) 35 + ->setViewer($viewer) 36 + ->withPHIDs(array($request->getValue('requestPHID'))) 37 + ->executeOne(); 34 38 35 39 $action = $request->getValue('action'); 36 40 ··· 38 42 39 43 $commit_message = array(); 40 44 41 - $project = $releeph_request->loadReleephProject(); 42 - $branch = $releeph_request->loadReleephBranch(); 45 + $branch = $releeph_request->getBranch(); 46 + $project = $branch->getProduct(); 43 47 44 48 $selector = $project->getReleephFieldSelector(); 45 49 $fields = $selector->getFieldSpecifications();
+5 -3
src/applications/releeph/conduit/work/ConduitAPI_releephwork_nextrequest_Method.php
··· 38 38 $viewer = $request->getUser(); 39 39 $seen = $request->getValue('seen'); 40 40 41 - $branch = id(new ReleephBranch()) 42 - ->loadOneWhere('phid = %s', $request->getValue('branchPHID')); 41 + $branch = id(new ReleephBranchQuery()) 42 + ->setViewer($viewer) 43 + ->withPHIDs(array($request->getValue('branchPHID'))) 44 + ->executeOne(); 43 45 44 - $project = $branch->loadReleephProject(); 46 + $project = $branch->getProduct(); 45 47 46 48 $needs_pick = array(); 47 49 $needs_revert = array();
+7 -5
src/applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php
··· 195 195 $rqs_seen = array(); 196 196 $groups = array(); 197 197 foreach ($releeph_requests as $releeph_request) { 198 - $releeph_branch = $releeph_request->loadReleephBranch(); 198 + $releeph_branch = $releeph_request->getBranch(); 199 199 $branch_name = $releeph_branch->getName(); 200 200 $rq_id = 'RQ'.$releeph_request->getID(); 201 201 ··· 252 252 return; 253 253 } 254 254 255 - $releeph_branch = head($releeph_requests)->loadReleephBranch(); 255 + $releeph_branch = head($releeph_requests)->getBranch(); 256 256 if (!$this->isCommitOnBranch($repo, $commit, $releeph_branch)) { 257 257 return; 258 258 } ··· 297 297 private function loadReleephRequests() { 298 298 if (!$this->releephPHIDs) { 299 299 return array(); 300 - } else { 301 - return id(new ReleephRequest()) 302 - ->loadAllWhere('phid IN (%Ls)', $this->releephPHIDs); 303 300 } 301 + 302 + return id(new ReleephRequestQuery()) 303 + ->setViewer($this->getViewer()) 304 + ->withPHIDs($this->releephPHIDs) 305 + ->execute(); 304 306 } 305 307 306 308 private function isCommitOnBranch(PhabricatorRepository $repo,
+4 -4
src/applications/releeph/editor/ReleephRequestTransactionalEditor.php
··· 204 204 protected function getMailTo(PhabricatorLiskDAO $object) { 205 205 $to_phids = array(); 206 206 207 - $releeph_project = $object->loadReleephProject(); 208 - foreach ($releeph_project->getPushers() as $phid) { 207 + $product = $object->getBranch()->getProduct(); 208 + foreach ($product->getPushers() as $phid) { 209 209 $to_phids[] = $phid; 210 210 } 211 211 ··· 227 227 $body = parent::buildMailBody($object, $xactions); 228 228 229 229 $rq = $object; 230 - $releeph_branch = $rq->loadReleephBranch(); 231 - $releeph_project = $releeph_branch->loadReleephProject(); 230 + $releeph_branch = $rq->getBranch(); 231 + $releeph_project = $releeph_branch->getProduct(); 232 232 233 233 /** 234 234 * If any of the events we are emailing about were about a pick failure
+14 -12
src/applications/releeph/query/ReleephRequestQuery.php
··· 89 89 90 90 public function willFilterPage(array $requests) { 91 91 92 - // TODO: These should be serviced by the query, but are not currently 93 - // denormalized anywhere. For now, filter them here instead. 94 - 95 - $keep_status = array_fuse($this->getKeepStatusConstants()); 96 - if ($keep_status) { 97 - foreach ($requests as $key => $request) { 98 - if (empty($keep_status[$request->getStatus()])) { 99 - unset($requests[$key]); 100 - } 101 - } 102 - } 103 - 104 92 if ($this->severities) { 105 93 $severities = array_fuse($this->severities); 106 94 foreach ($requests as $key => $request) { ··· 131 119 continue; 132 120 } 133 121 $request->attachBranch($branch); 122 + } 123 + 124 + // TODO: These should be serviced by the query, but are not currently 125 + // denormalized anywhere. For now, filter them here instead. Note that 126 + // we must perform this filtering *after* querying and attaching branches, 127 + // because request status depends on the product. 128 + 129 + $keep_status = array_fuse($this->getKeepStatusConstants()); 130 + if ($keep_status) { 131 + foreach ($requests as $key => $request) { 132 + if (empty($keep_status[$request->getStatus()])) { 133 + unset($requests[$key]); 134 + } 135 + } 134 136 } 135 137 136 138 return $requests;
+3 -11
src/applications/releeph/storage/ReleephBranch.php
··· 94 94 95 95 public function getURI($path = null) { 96 96 $components = array( 97 - '/releeph', 98 - rawurlencode($this->loadReleephProject()->getName()), 99 - rawurlencode($this->getBasename()), 100 - $path 97 + '/releeph/branch', 98 + $this->getID(), 99 + $path, 101 100 ); 102 101 return implode('/', $components); 103 - } 104 - 105 - public function loadReleephProject() { 106 - return $this->loadOneRelative( 107 - new ReleephProject(), 108 - 'id', 109 - 'getReleephProjectID'); 110 102 } 111 103 112 104 public function isActive() {
+1 -1
src/applications/releeph/storage/ReleephProject.php
··· 42 42 43 43 public function getURI($path = null) { 44 44 $components = array( 45 - '/releeph/project', 45 + '/releeph/product', 46 46 $this->getID(), 47 47 $path 48 48 );
+3 -20
src/applications/releeph/storage/ReleephRequest.php
··· 52 52 * passes on this request. 53 53 */ 54 54 public function getPusherIntent() { 55 - $project = $this->loadReleephProject(); 56 - if (!$project) { 57 - return null; 58 - } 55 + $product = $this->getBranch()->getProduct(); 59 56 60 - if (!$project->getPushers()) { 57 + if (!$product->getPushers()) { 61 58 return self::INTENT_WANT; 62 59 } 63 60 64 61 $found_pusher_want = false; 65 62 foreach ($this->userIntents as $phid => $intent) { 66 - if ($project->isAuthoritativePHID($phid)) { 63 + if ($product->isAuthoritativePHID($phid)) { 67 64 if ($intent == self::INTENT_PASS) { 68 65 return self::INTENT_PASS; 69 66 } ··· 209 206 210 207 211 208 /* -( Loading external objects )------------------------------------------- */ 212 - 213 - public function loadReleephBranch() { 214 - return $this->loadOneRelative( 215 - new ReleephBranch(), 216 - 'id', 217 - 'getBranchID'); 218 - } 219 - 220 - public function loadReleephProject() { 221 - $branch = $this->loadReleephBranch(); 222 - if ($branch) { 223 - return $branch->loadReleephProject(); 224 - } 225 - } 226 209 227 210 public function loadPhabricatorRepositoryCommit() { 228 211 return $this->loadOneRelative(