@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

Simplify ReleephRequest schema

Summary:
Removing a bunch of cache-style columns from `ReleephRequest`, where it's actually much easier to just load the information at runtime.

This makes sense for migrating to `PhabricatorApplicationTransactions`, where each xaction changes one aspect of a `ReleephRequest` at a time (rather than multiple columns at once.)

Test Plan: Request something, run `arc releeph` and watch the picks, pass on some RQs, run `arc releeph` and watch the reverts.

Reviewers: wez, epriestley

Reviewed By: epriestley

CC: epriestley, aran

Maniphest Tasks: T2720

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

+34 -17
+8
resources/sql/patches/20130507.releephrqsimplifycols.sql
··· 1 + ALTER TABLE {$NAMESPACE}_releeph.releeph_request 2 + DROP COLUMN requestCommitIdentifier, 3 + DROP COLUMN requestCommitOrdinal, 4 + DROP COLUMN status, 5 + DROP COLUMN committedByUserPHID, 6 + DROP KEY `requestIdentifierBranch`, 7 + ADD CONSTRAINT 8 + UNIQUE KEY `requestIdentifierBranch` (`requestCommitPHID`, `branchID`);
+16 -3
src/applications/releeph/conduit/work/ConduitAPI_releephwork_nextrequest_Method.php
··· 71 71 * This is easy for $needs_pick as the ordinal is stored. It is hard for 72 72 * reverts, as we have to look that information up. 73 73 */ 74 - $needs_pick = msort($needs_pick, 'getRequestCommitOrdinal'); 74 + $needs_pick = $this->sortPicks($needs_pick); 75 75 $needs_revert = $this->sortReverts($needs_revert); 76 76 77 77 /** ··· 95 95 } elseif ($needs_pick) { 96 96 $releeph_request = head($needs_pick); 97 97 $action = 'pick'; 98 - $commit_id = $releeph_request->getRequestCommitIdentifier(); 99 - $commit_phid = $releeph_request->getRequestCommitPHID(); 98 + $commit = $releeph_request->loadPhabricatorRepositoryCommit(); 99 + $commit_id = $commit->getCommitIdentifier(); 100 + $commit_phid = $commit->getPHID(); 100 101 } else { 101 102 // Return early if there's nothing to do! 102 103 return array(); ··· 163 164 'needsPick' => mpull($needs_pick, 'getID'), 164 165 'newAuthorPHID' => $new_author_phid, 165 166 ); 167 + } 168 + 169 + private function sortPicks(array $releeph_requests) { 170 + $surrogate = array(); 171 + foreach ($releeph_requests as $rq) { 172 + // TODO: it's likely that relying on the `id` column to provide 173 + // trunk-commit-order is thoroughly broken. 174 + $ordinal = (int) $rq->loadPhabricatorRepositoryCommit()->getID(); 175 + $surrogate[$ordinal] = $rq; 176 + } 177 + ksort($surrogate); 178 + return $surrogate; 166 179 } 167 180 168 181 /**
-1
src/applications/releeph/controller/request/ReleephRequestEditController.php
··· 14 14 $phids = array(); 15 15 $phids[] = $releeph_request->getRequestCommitPHID(); 16 16 $phids[] = $releeph_request->getRequestUserPHID(); 17 - $phids[] = $releeph_request->getCommittedByUserPHID(); 18 17 19 18 $handles = id(new PhabricatorObjectHandleData($phids)) 20 19 ->setViewer($request->getUser())
-6
src/applications/releeph/editor/ReleephRequestEditor.php
··· 44 44 45 45 $rq 46 46 ->setBranchID($branch->getID()) 47 - ->setRequestCommitIdentifier($commit->getCommitIdentifier()) 48 47 ->setRequestCommitPHID($commit->getPHID()) 49 - ->setRequestCommitOrdinal($commit->getID()) 50 48 ->setInBranch(0) 51 49 ->setRequestUserPHID($requestor->getPHID()) 52 50 ->setUserIntent($requestor, ReleephRequest::INTENT_WANT) ··· 177 175 ->setPickStatus(ReleephRequest::PICK_OK) 178 176 ->setCommitIdentifier($new_commit_id) 179 177 ->setCommitPHID(null) 180 - ->setCommittedByUserPHID($actor->getPHID()) 181 178 ->save(); 182 179 break; 183 180 ··· 187 184 ->setPickStatus(ReleephRequest::REVERT_OK) 188 185 ->setCommitIdentifier(null) 189 186 ->setCommitPHID(null) 190 - ->setCommittedByUserPHID(null) 191 187 ->save(); 192 188 break; 193 189 ··· 254 250 ->setPickStatus(ReleephRequest::PICK_OK) 255 251 ->setCommitIdentifier($commit->getCommitIdentifier()) 256 252 ->setCommitPHID($commit->getPHID()) 257 - ->setCommittedByUserPHID($actor->getPHID()) 258 253 ->save(); 259 254 break; 260 255 ··· 264 259 ->setPickStatus(ReleephRequest::REVERT_OK) 265 260 ->setCommitIdentifier(null) 266 261 ->setCommitPHID(null) 267 - ->setCommittedByUserPHID(null) 268 262 ->save(); 269 263 break; 270 264
+6 -7
src/applications/releeph/storage/ReleephRequest.php
··· 11 11 protected $pickStatus; 12 12 13 13 // Information about the thing being requested 14 - protected $requestCommitIdentifier; 15 14 protected $requestCommitPHID; 16 - protected $requestCommitOrdinal; 17 15 18 16 // Information about the last commit to the releeph branch 19 17 protected $commitIdentifier; 20 - protected $committedByUserPHID; 21 18 protected $commitPHID; 22 19 23 20 // Pre-populated handles that we'll bulk load in ReleephBranch ··· 267 264 } 268 265 269 266 public function loadPhabricatorRepositoryCommitData() { 270 - return $this->loadOneRelative( 271 - new PhabricatorRepositoryCommitData(), 272 - 'commitID', 273 - 'getRequestCommitOrdinal'); 267 + $commit = $this->loadPhabricatorRepositoryCommit(); 268 + if ($commit) { 269 + return $commit->loadOneRelative( 270 + new PhabricatorRepositoryCommitData(), 271 + 'commitID'); 272 + } 274 273 } 275 274 276 275 public function loadDifferentialRevision() {
+4
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 1270 1270 'type' => 'sql', 1271 1271 'name' => $this->getPatchPath('20130502.countdownrevamp3.sql'), 1272 1272 ), 1273 + '20130507.releephrqsimplifycols.sql' => array( 1274 + 'type' => 'sql', 1275 + 'name' => $this->getPatchPath('20130507.releephrqsimplifycols.sql'), 1276 + ), 1273 1277 ); 1274 1278 } 1275 1279 }