Page MenuHomePhabricator

D18946.id45443.diff
No OneTemporary

D18946.id45443.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2747,6 +2747,7 @@
'PhabricatorDraftEngine' => 'applications/transactions/draft/PhabricatorDraftEngine.php',
'PhabricatorDraftInterface' => 'applications/transactions/draft/PhabricatorDraftInterface.php',
'PhabricatorDrydockApplication' => 'applications/drydock/application/PhabricatorDrydockApplication.php',
+ 'PhabricatorEdgeChangeRecord' => 'infrastructure/edges/util/PhabricatorEdgeChangeRecord.php',
'PhabricatorEdgeConfig' => 'infrastructure/edges/constants/PhabricatorEdgeConfig.php',
'PhabricatorEdgeConstants' => 'infrastructure/edges/constants/PhabricatorEdgeConstants.php',
'PhabricatorEdgeCycleException' => 'infrastructure/edges/exception/PhabricatorEdgeCycleException.php',
@@ -8170,6 +8171,7 @@
'PhabricatorDraftDAO' => 'PhabricatorLiskDAO',
'PhabricatorDraftEngine' => 'Phobject',
'PhabricatorDrydockApplication' => 'PhabricatorApplication',
+ 'PhabricatorEdgeChangeRecord' => 'Phobject',
'PhabricatorEdgeConfig' => 'PhabricatorEdgeConstants',
'PhabricatorEdgeConstants' => 'Phobject',
'PhabricatorEdgeCycleException' => 'Exception',
diff --git a/src/applications/differential/storage/DifferentialTransaction.php b/src/applications/differential/storage/DifferentialTransaction.php
--- a/src/applications/differential/storage/DifferentialTransaction.php
+++ b/src/applications/differential/storage/DifferentialTransaction.php
@@ -87,19 +87,6 @@
}
break;
- case PhabricatorTransactions::TYPE_EDGE:
- $add = array_diff_key($new, $old);
- $rem = array_diff_key($old, $new);
-
- // Hide metadata-only edge transactions. These correspond to users
- // accepting or rejecting revisions, but the change is always explicit
- // because of the TYPE_ACTION transaction. Rendering these transactions
- // just creates clutter.
-
- if (!$add && !$rem) {
- return true;
- }
- break;
case DifferentialRevisionRequestReviewTransaction::TRANSACTIONTYPE:
// Don't hide the initial "X requested review: ..." transaction from
// mail or feed even when it occurs during creation. We need this
diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
--- a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
+++ b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
@@ -302,8 +302,8 @@
$phids[] = $new;
break;
case PhabricatorTransactions::TYPE_EDGE:
- $phids[] = ipull($old, 'dst');
- $phids[] = ipull($new, 'dst');
+ $record = PhabricatorEdgeChangeRecord::newFromTransaction($this);
+ $phids[] = $record->getChangedPHIDs();
break;
case PhabricatorTransactions::TYPE_COLUMNS:
foreach ($new as $move) {
@@ -632,9 +632,8 @@
return true;
break;
case PhabricatorObjectMentionedByObjectEdgeType::EDGECONST:
- $new = ipull($this->getNewValue(), 'dst');
- $old = ipull($this->getOldValue(), 'dst');
- $add = array_diff($new, $old);
+ $record = PhabricatorEdgeChangeRecord::newFromTransaction($this);
+ $add = $record->getAddedPHIDs();
$add_value = reset($add);
$add_handle = $this->getHandle($add_value);
if ($add_handle->getPolicyFiltered()) {
@@ -933,10 +932,10 @@
}
break;
case PhabricatorTransactions::TYPE_EDGE:
- $new = ipull($new, 'dst');
- $old = ipull($old, 'dst');
- $add = array_diff($new, $old);
- $rem = array_diff($old, $new);
+ $record = PhabricatorEdgeChangeRecord::newFromTransaction($this);
+ $add = $record->getAddedPHIDs();
+ $rem = $record->getRemovedPHIDs();
+
$type = $this->getMetadata('edge:type');
$type = head($type);
@@ -1172,10 +1171,10 @@
$this->renderHandleLink($new));
}
case PhabricatorTransactions::TYPE_EDGE:
- $new = ipull($new, 'dst');
- $old = ipull($old, 'dst');
- $add = array_diff($new, $old);
- $rem = array_diff($old, $new);
+ $record = PhabricatorEdgeChangeRecord::newFromTransaction($this);
+ $add = $record->getAddedPHIDs();
+ $rem = $record->getRemovedPHIDs();
+
$type = $this->getMetadata('edge:type');
$type = head($type);
diff --git a/src/infrastructure/edges/util/PhabricatorEdgeChangeRecord.php b/src/infrastructure/edges/util/PhabricatorEdgeChangeRecord.php
new file mode 100644
--- /dev/null
+++ b/src/infrastructure/edges/util/PhabricatorEdgeChangeRecord.php
@@ -0,0 +1,68 @@
+<?php
+
+final class PhabricatorEdgeChangeRecord
+ extends Phobject {
+
+ private $xaction;
+
+ public static function newFromTransaction(
+ PhabricatorApplicationTransaction $xaction) {
+ $record = new self();
+ $record->xaction = $xaction;
+ return $record;
+ }
+
+ public function getChangedPHIDs() {
+ $add = $this->getAddedPHIDs();
+ $rem = $this->getRemovedPHIDs();
+
+ $add = array_fuse($add);
+ $rem = array_fuse($rem);
+
+ return array_keys($add + $rem);
+ }
+
+ public function getAddedPHIDs() {
+ $old = $this->getOldDestinationPHIDs();
+ $new = $this->getNewDestinationPHIDs();
+
+ $old = array_fuse($old);
+ $new = array_fuse($new);
+
+ $add = array_diff_key($new, $old);
+ return array_keys($add);
+ }
+
+ public function getRemovedPHIDs() {
+ $old = $this->getOldDestinationPHIDs();
+ $new = $this->getNewDestinationPHIDs();
+
+ $old = array_fuse($old);
+ $new = array_fuse($new);
+
+ $rem = array_diff_key($old, $new);
+ return array_keys($rem);
+ }
+
+ private function getOldDestinationPHIDs() {
+ if ($this->xaction) {
+ $old = $this->xaction->getOldValue();
+ return ipull($old, 'dst');
+ }
+
+ throw new Exception(
+ pht('Edge change record is not configured with any change data.'));
+ }
+
+ private function getNewDestinationPHIDs() {
+ if ($this->xaction) {
+ $new = $this->xaction->getNewValue();
+ return ipull($new, 'dst');
+ }
+
+ throw new Exception(
+ pht('Edge change record is not configured with any change data.'));
+ }
+
+
+}

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 9, 3:59 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7226730
Default Alt Text
D18946.id45443.diff (6 KB)

Event Timeline