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

Wrap edge transaction readers in a translation layer

Summary:
Ref T13051. This puts a translation layer between the raw edge data in the transaction table and the UI that uses it.

The intent is to start writing new, more compact data soon. This class give us a consistent API for interacting with either the new or old data format, so we don't have to migrate everything upfront.

Test Plan: Browsed around, saw existing edge transactions render properly in transactions and feed. Added and removed subscribers and projects, saw good transaction rendering.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13051

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

+82 -26
+2
src/__phutil_library_map__.php
··· 2747 2747 'PhabricatorDraftEngine' => 'applications/transactions/draft/PhabricatorDraftEngine.php', 2748 2748 'PhabricatorDraftInterface' => 'applications/transactions/draft/PhabricatorDraftInterface.php', 2749 2749 'PhabricatorDrydockApplication' => 'applications/drydock/application/PhabricatorDrydockApplication.php', 2750 + 'PhabricatorEdgeChangeRecord' => 'infrastructure/edges/util/PhabricatorEdgeChangeRecord.php', 2750 2751 'PhabricatorEdgeConfig' => 'infrastructure/edges/constants/PhabricatorEdgeConfig.php', 2751 2752 'PhabricatorEdgeConstants' => 'infrastructure/edges/constants/PhabricatorEdgeConstants.php', 2752 2753 'PhabricatorEdgeCycleException' => 'infrastructure/edges/exception/PhabricatorEdgeCycleException.php', ··· 8170 8171 'PhabricatorDraftDAO' => 'PhabricatorLiskDAO', 8171 8172 'PhabricatorDraftEngine' => 'Phobject', 8172 8173 'PhabricatorDrydockApplication' => 'PhabricatorApplication', 8174 + 'PhabricatorEdgeChangeRecord' => 'Phobject', 8173 8175 'PhabricatorEdgeConfig' => 'PhabricatorEdgeConstants', 8174 8176 'PhabricatorEdgeConstants' => 'Phobject', 8175 8177 'PhabricatorEdgeCycleException' => 'Exception',
-13
src/applications/differential/storage/DifferentialTransaction.php
··· 87 87 } 88 88 break; 89 89 90 - case PhabricatorTransactions::TYPE_EDGE: 91 - $add = array_diff_key($new, $old); 92 - $rem = array_diff_key($old, $new); 93 - 94 - // Hide metadata-only edge transactions. These correspond to users 95 - // accepting or rejecting revisions, but the change is always explicit 96 - // because of the TYPE_ACTION transaction. Rendering these transactions 97 - // just creates clutter. 98 - 99 - if (!$add && !$rem) { 100 - return true; 101 - } 102 - break; 103 90 case DifferentialRevisionRequestReviewTransaction::TRANSACTIONTYPE: 104 91 // Don't hide the initial "X requested review: ..." transaction from 105 92 // mail or feed even when it occurs during creation. We need this
+12 -13
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
··· 302 302 $phids[] = $new; 303 303 break; 304 304 case PhabricatorTransactions::TYPE_EDGE: 305 - $phids[] = ipull($old, 'dst'); 306 - $phids[] = ipull($new, 'dst'); 305 + $record = PhabricatorEdgeChangeRecord::newFromTransaction($this); 306 + $phids[] = $record->getChangedPHIDs(); 307 307 break; 308 308 case PhabricatorTransactions::TYPE_COLUMNS: 309 309 foreach ($new as $move) { ··· 632 632 return true; 633 633 break; 634 634 case PhabricatorObjectMentionedByObjectEdgeType::EDGECONST: 635 - $new = ipull($this->getNewValue(), 'dst'); 636 - $old = ipull($this->getOldValue(), 'dst'); 637 - $add = array_diff($new, $old); 635 + $record = PhabricatorEdgeChangeRecord::newFromTransaction($this); 636 + $add = $record->getAddedPHIDs(); 638 637 $add_value = reset($add); 639 638 $add_handle = $this->getHandle($add_value); 640 639 if ($add_handle->getPolicyFiltered()) { ··· 933 932 } 934 933 break; 935 934 case PhabricatorTransactions::TYPE_EDGE: 936 - $new = ipull($new, 'dst'); 937 - $old = ipull($old, 'dst'); 938 - $add = array_diff($new, $old); 939 - $rem = array_diff($old, $new); 935 + $record = PhabricatorEdgeChangeRecord::newFromTransaction($this); 936 + $add = $record->getAddedPHIDs(); 937 + $rem = $record->getRemovedPHIDs(); 938 + 940 939 $type = $this->getMetadata('edge:type'); 941 940 $type = head($type); 942 941 ··· 1172 1171 $this->renderHandleLink($new)); 1173 1172 } 1174 1173 case PhabricatorTransactions::TYPE_EDGE: 1175 - $new = ipull($new, 'dst'); 1176 - $old = ipull($old, 'dst'); 1177 - $add = array_diff($new, $old); 1178 - $rem = array_diff($old, $new); 1174 + $record = PhabricatorEdgeChangeRecord::newFromTransaction($this); 1175 + $add = $record->getAddedPHIDs(); 1176 + $rem = $record->getRemovedPHIDs(); 1177 + 1179 1178 $type = $this->getMetadata('edge:type'); 1180 1179 $type = head($type); 1181 1180
+68
src/infrastructure/edges/util/PhabricatorEdgeChangeRecord.php
··· 1 + <?php 2 + 3 + final class PhabricatorEdgeChangeRecord 4 + extends Phobject { 5 + 6 + private $xaction; 7 + 8 + public static function newFromTransaction( 9 + PhabricatorApplicationTransaction $xaction) { 10 + $record = new self(); 11 + $record->xaction = $xaction; 12 + return $record; 13 + } 14 + 15 + public function getChangedPHIDs() { 16 + $add = $this->getAddedPHIDs(); 17 + $rem = $this->getRemovedPHIDs(); 18 + 19 + $add = array_fuse($add); 20 + $rem = array_fuse($rem); 21 + 22 + return array_keys($add + $rem); 23 + } 24 + 25 + public function getAddedPHIDs() { 26 + $old = $this->getOldDestinationPHIDs(); 27 + $new = $this->getNewDestinationPHIDs(); 28 + 29 + $old = array_fuse($old); 30 + $new = array_fuse($new); 31 + 32 + $add = array_diff_key($new, $old); 33 + return array_keys($add); 34 + } 35 + 36 + public function getRemovedPHIDs() { 37 + $old = $this->getOldDestinationPHIDs(); 38 + $new = $this->getNewDestinationPHIDs(); 39 + 40 + $old = array_fuse($old); 41 + $new = array_fuse($new); 42 + 43 + $rem = array_diff_key($old, $new); 44 + return array_keys($rem); 45 + } 46 + 47 + private function getOldDestinationPHIDs() { 48 + if ($this->xaction) { 49 + $old = $this->xaction->getOldValue(); 50 + return ipull($old, 'dst'); 51 + } 52 + 53 + throw new Exception( 54 + pht('Edge change record is not configured with any change data.')); 55 + } 56 + 57 + private function getNewDestinationPHIDs() { 58 + if ($this->xaction) { 59 + $new = $this->xaction->getNewValue(); 60 + return ipull($new, 'dst'); 61 + } 62 + 63 + throw new Exception( 64 + pht('Edge change record is not configured with any change data.')); 65 + } 66 + 67 + 68 + }