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

Summary: Ref T3663. This is obsolete code which is used only in this migration, which Facebook has already performed and which isn't relevant for any other installs.

Test Plan: `grep`

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3663

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

+5 -232
+5 -128
resources/sql/patches/20130508.releephtransactionsmig.php
··· 1 1 <?php 2 2 3 - echo "Migrating Releeph requests events to transactions...\n"; 4 - 5 - $table = new ReleephRequest(); 6 - $table->openTransaction(); 7 - $table->beginReadLocking(); 8 - 9 - foreach (new LiskMigrationIterator($table) as $rq) { 10 - printf("RQ%d:", $rq->getID()); 11 - 12 - $intents_cursor = array(); 13 - $last_pick_status = null; 14 - $last_commit_id = null; 15 - 16 - foreach ($rq->loadEvents() as $event) { 17 - $author = $event->getActorPHID(); 18 - $details = $event->getDetails(); 19 - 20 - $content_source = PhabricatorContentSource::newForSource( 21 - PhabricatorContentSource::SOURCE_UNKNOWN, 22 - array('ReleephRequestEventID' => $event->getID())); 3 + // Previously, this migrated ReleephRequestEvents into ApplicationTransactions. 4 + // Only Facebook ever generated meaningful ReleephRequestEvent data, and has 5 + // already migrated, so this was cleaned up when ReleephRequestEvent was 6 + // removed. 23 7 24 - $xaction = id(new ReleephRequestTransaction()) 25 - ->setObjectPHID($rq->getPHID()) 26 - ->setAuthorPHID($author) 27 - ->setContentSource($content_source) 28 - ->setDateCreated($event->getDateCreated()) 29 - ->setDateModified($event->getDateModified()) 30 - ->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC) 31 - ->setEditPolicy($author); 32 - 33 - printf(" %s(#%d)", $event->getType(), $event->getID()); 34 - 35 - switch ($event->getType()) { 36 - case ReleephRequestEvent::TYPE_COMMENT: 37 - $xaction 38 - ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 39 - ->save(); // to generate a PHID 40 - $comment = id(new ReleephRequestTransactionComment()) 41 - ->setAuthorPHID($author) 42 - ->setTransactionPHID($xaction->getPHID()) 43 - ->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC) 44 - ->setEditPolicy($author) 45 - ->setCommentVersion(1) 46 - ->setContent($event->getComment()) 47 - ->setContentSource($content_source) 48 - ->save(); 49 - $xaction 50 - ->setCommentPHID($comment->getPHID()) 51 - ->setCommentVersion(1); 52 - break; 53 - 54 - case ReleephRequestEvent::TYPE_STATUS: 55 - // Ignore STATUS events; these are legacy events that we no longer 56 - // support anyway! 57 - continue 2; 58 - 59 - case ReleephRequestEvent::TYPE_USER_INTENT: 60 - $old_intent = idx($intents_cursor, $author); 61 - $new_intent = $event->getDetail('newIntent'); 62 - $xaction 63 - ->setTransactionType(ReleephRequestTransaction::TYPE_USER_INTENT) 64 - ->setMetadataValue('isAuthoritative', $event->getDetail('wasPusher')) 65 - ->setOldValue($old_intent) 66 - ->setNewValue($new_intent); 67 - $intents_cursor[$author] = $new_intent; 68 - break; 69 - 70 - case ReleephRequestEvent::TYPE_PICK_STATUS: 71 - $new_pick_status = $event->getDetail('newPickStatus'); 72 - $xaction 73 - ->setTransactionType(ReleephRequestTransaction::TYPE_PICK_STATUS) 74 - ->setOldValue($last_pick_status) 75 - ->setNewValue($new_pick_status); 76 - $last_pick_status = $new_pick_status; 77 - break; 78 - 79 - case ReleephRequestEvent::TYPE_COMMIT: 80 - $new_commit_id = $event->getDetail('newCommitIdentifier'); 81 - $xaction 82 - ->setTransactionType(ReleephRequestTransaction::TYPE_COMMIT) 83 - ->setMetadataValue('action', $event->getDetail('action')) 84 - ->setOldValue($last_commit_id) 85 - ->setNewValue($new_commit_id); 86 - $last_commit_id = $new_commit_id; 87 - break; 88 - 89 - case ReleephRequestEvent::TYPE_DISCOVERY: 90 - $xaction 91 - ->setTransactionType(ReleephRequestTransaction::TYPE_DISCOVERY) 92 - ->setNewValue($event->getDetail('newCommitPHID')); 93 - break; 94 - 95 - case ReleephRequestEvent::TYPE_CREATE: 96 - $xaction 97 - ->setTransactionType(ReleephRequestTransaction::TYPE_REQUEST) 98 - ->setOldValue(null) 99 - ->setNewValue($rq->getRequestCommitPHID()); 100 - break; 101 - 102 - case ReleephRequestEvent::TYPE_MANUAL_ACTION: 103 - $xaction 104 - ->setTransactionType( 105 - ReleephRequestTransaction::TYPE_MANUAL_IN_BRANCH); 106 - switch ($event->getDetail('action')) { 107 - case 'pick': 108 - $xaction->setNewValue(1); 109 - break; 110 - 111 - case 'revert': 112 - $xaction->setNewValue(0); 113 - break; 114 - } 115 - break; 116 - 117 - default: 118 - throw new Exception(sprintf( 119 - "Unhandled ReleephRequestEvent type '%s' in RQ%d", 120 - $event->getType(), 121 - $rq->getID())); 122 - } 123 - 124 - $xaction->save(); 125 - } 126 - echo("\n"); 127 - } 128 - 129 - $table->endReadLocking(); 130 - $table->saveTransaction(); 131 - echo "Done.\n"; 8 + echo "(This migration is obsolete.)\n";
-2
src/__phutil_library_map__.php
··· 1987 1987 'ReleephRequestCommentController' => 'applications/releeph/controller/request/ReleephRequestCommentController.php', 1988 1988 'ReleephRequestDifferentialCreateController' => 'applications/releeph/controller/request/ReleephRequestDifferentialCreateController.php', 1989 1989 'ReleephRequestEditController' => 'applications/releeph/controller/request/ReleephRequestEditController.php', 1990 - 'ReleephRequestEvent' => 'applications/releeph/storage/request/ReleephRequestEvent.php', 1991 1990 'ReleephRequestException' => 'applications/releeph/storage/request/exception/ReleephRequestException.php', 1992 1991 'ReleephRequestHeaderListView' => 'applications/releeph/view/request/header/ReleephRequestHeaderListView.php', 1993 1992 'ReleephRequestHeaderView' => 'applications/releeph/view/request/header/ReleephRequestHeaderView.php', ··· 4189 4188 'ReleephRequestCommentController' => 'ReleephProjectController', 4190 4189 'ReleephRequestDifferentialCreateController' => 'ReleephProjectController', 4191 4190 'ReleephRequestEditController' => 'ReleephProjectController', 4192 - 'ReleephRequestEvent' => 'ReleephDAO', 4193 4191 'ReleephRequestException' => 'Exception', 4194 4192 'ReleephRequestHeaderListView' => 'AphrontView', 4195 4193 'ReleephRequestHeaderView' => 'AphrontView',
-8
src/applications/releeph/storage/ReleephRequest.php
··· 234 234 return $this->loadReleephBranch()->loadReleephProject(); 235 235 } 236 236 237 - public function loadEvents() { 238 - return $this->loadRelatives( 239 - new ReleephRequestEvent(), 240 - 'releephRequestID', 241 - 'getID', 242 - '(1 = 1) ORDER BY dateCreated, id'); 243 - } 244 - 245 237 public function loadPhabricatorRepositoryCommit() { 246 238 return $this->loadOneRelative( 247 239 new PhabricatorRepositoryCommit(),
-94
src/applications/releeph/storage/request/ReleephRequestEvent.php
··· 1 - <?php 2 - 3 - final class ReleephRequestEvent extends ReleephDAO { 4 - 5 - const TYPE_CREATE = 'create'; 6 - const TYPE_STATUS = 'status'; // old events 7 - const TYPE_USER_INTENT = 'user-intent'; 8 - const TYPE_PICK_STATUS = 'pick-status'; 9 - const TYPE_COMMIT = 'commit'; 10 - const TYPE_MANUAL_ACTION = 'manual-action'; 11 - const TYPE_DISCOVERY = 'discovery'; 12 - const TYPE_COMMENT = 'comment'; 13 - 14 - protected $releephRequestID; 15 - protected $type; 16 - protected $actorPHID; 17 - protected $details = array(); 18 - 19 - public function getConfiguration() { 20 - return array( 21 - self::CONFIG_SERIALIZATION => array( 22 - 'details' => self::SERIALIZATION_JSON, 23 - ), 24 - ) + parent::getConfiguration(); 25 - } 26 - 27 - public function getDetail($key, $default = null) { 28 - return idx($this->details, $key, $default); 29 - } 30 - 31 - public function setDetail($key, $value) { 32 - $this->details[$key] = $value; 33 - return $this; 34 - } 35 - 36 - private function setDetails(array $details) { 37 - throw new Exception('Use setDetail()!'); 38 - } 39 - 40 - public function setStatusBefore($status) { 41 - return $this->setDetail('oldStatus', $status); 42 - } 43 - 44 - public function setStatusAfter($status) { 45 - return $this->setDetail('newStatus', $status); 46 - } 47 - 48 - public function getStatusBefore() { 49 - return $this->getDetail('oldStatus'); 50 - } 51 - 52 - public function getStatusAfter() { 53 - return $this->getDetail('newStatus'); 54 - } 55 - 56 - public function getComment() { 57 - return $this->getDetail('comment'); 58 - } 59 - 60 - public function extractPHIDs() { 61 - $phids = array(); 62 - $phids[] = $this->actorPHID; 63 - foreach ($this->details as $key => $value) { 64 - if (strpos($key, 'PHID') !== false || strpos($key, 'phid') !== false) { 65 - $phids[] = $value; 66 - } 67 - } 68 - return $phids; 69 - } 70 - 71 - public function canGroupWith(ReleephRequestEvent $next) { 72 - if ($this->getActorPHID() != $next->getActorPHID()) { 73 - return false; 74 - } 75 - 76 - if ($this->getComment() && $next->getComment()) { 77 - return false; 78 - } 79 - 80 - // Break the chain if the next event changes the status 81 - if ($next->getStatusBefore() != $next->getStatusAfter()) { 82 - return false; 83 - } 84 - 85 - // Don't group if the next event starts off with a different status to the 86 - // one we ended with. This probably shouldn't ever happen. 87 - if ($this->getStatusAfter() != $next->getStatusBefore()) { 88 - return false; 89 - } 90 - 91 - return true; 92 - } 93 - 94 - }