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

Convert revision unsubscribers to edges

Test Plan: Ran the migration on a single revision, verified DB, called `loadUnsubscribedPHIDs()`.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

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

vrana 8c99938a ccb206e9

+56 -16
+33
resources/sql/patches/20130201.revisionunsubscribed.php
··· 1 + <?php 2 + 3 + echo "Migrating Differential unsubscribed users to edges...\n"; 4 + $table = new DifferentialRevision(); 5 + $table->openTransaction(); 6 + 7 + // We couldn't use new LiskMigrationIterator($table) because the $unsubscribed 8 + // property gets deleted. 9 + $revs = queryfx_all( 10 + $table->establishConnection('w'), 11 + 'SELECT id, phid, unsubscribed FROM differential_revision'); 12 + 13 + foreach ($revs as $rev) { 14 + echo "."; 15 + 16 + $unsubscribed = json_decode($rev['unsubscribed']); 17 + if (!$unsubscribed) { 18 + continue; 19 + } 20 + 21 + $editor = new PhabricatorEdgeEditor(); 22 + $editor->setSuppressEvents(true); 23 + foreach ($unsubscribed as $user_phid => $_) { 24 + $editor->addEdge( 25 + $rev['phid'], 26 + PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER, 27 + $user_phid); 28 + } 29 + $editor->save(); 30 + } 31 + 32 + $table->saveTransaction(); 33 + echo "Done.\n";
+2
resources/sql/patches/20130201.revisionunsubscribed.sql
··· 1 + ALTER TABLE {$NAMESPACE}_differential.differential_revision 2 + DROP unsubscribed;
+9 -13
src/applications/differential/editor/DifferentialRevisionEditor.php
··· 238 238 $diff); 239 239 $adapter->setExplicitCCs($new['ccs']); 240 240 $adapter->setExplicitReviewers($new['rev']); 241 - $adapter->setForbiddenCCs($revision->getUnsubscribedPHIDs()); 241 + $adapter->setForbiddenCCs($revision->loadUnsubscribedPHIDs()); 242 242 243 243 $xscript = HeraldEngine::loadAndApplyRules($adapter); 244 244 $xscript_uri = '/herald/transcript/'.$xscript->getID().'/'; ··· 500 500 501 501 self::addCC($revision, $phid, $reason); 502 502 503 - $unsubscribed = $revision->getUnsubscribed(); 504 - if (isset($unsubscribed[$phid])) { 505 - unset($unsubscribed[$phid]); 506 - $revision->setUnsubscribed($unsubscribed); 507 - $revision->save(); 508 - } 503 + $type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER; 504 + id(new PhabricatorEdgeEditor()) 505 + ->removeEdge($revision->getPHID(), $type, $phid) 506 + ->save(); 509 507 } 510 508 511 509 public static function removeCCAndUpdateRevision( ··· 515 513 516 514 self::removeCC($revision, $phid, $reason); 517 515 518 - $unsubscribed = $revision->getUnsubscribed(); 519 - if (empty($unsubscribed[$phid])) { 520 - $unsubscribed[$phid] = true; 521 - $revision->setUnsubscribed($unsubscribed); 522 - $revision->save(); 523 - } 516 + $type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER; 517 + id(new PhabricatorEdgeEditor()) 518 + ->addEdge($revision->getPHID(), $type, $phid) 519 + ->save(); 524 520 } 525 521 526 522 public static function addCC(
+4 -3
src/applications/differential/storage/DifferentialRevision.php
··· 17 17 18 18 protected $lineCount; 19 19 protected $attached = array(); 20 - protected $unsubscribed = array(); 21 20 22 21 protected $mailKey; 23 22 protected $branchName; ··· 264 263 return idx($this->relationships, $relation, array()); 265 264 } 266 265 267 - public function getUnsubscribedPHIDs() { 268 - return array_keys($this->getUnsubscribed()); 266 + public function loadUnsubscribedPHIDs() { 267 + return PhabricatorEdgeQuery::loadDestinationPHIDs( 268 + $this->phid, 269 + PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER); 269 270 } 270 271 271 272 public function getPrimaryReviewer() {
+8
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 1097 1097 'type' => 'sql', 1098 1098 'name' => $this->getPatchPath('20130127.altheraldtranscript.sql'), 1099 1099 ), 1100 + '20130201.revisionunsubscribed.php' => array( 1101 + 'type' => 'php', 1102 + 'name' => $this->getPatchPath('20130201.revisionunsubscribed.php'), 1103 + ), 1104 + '20130201.revisionunsubscribed.sql' => array( 1105 + 'type' => 'sql', 1106 + 'name' => $this->getPatchPath('20130201.revisionunsubscribed.sql'), 1107 + ), 1100 1108 ); 1101 1109 } 1102 1110