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

Write edge transactions in a more compact way

Summary: Depends on D18946. Ref T13051. Begins writing edge transactions as just a list of changed PHIDs.

Test Plan: Added, edited, and removed projects. Reviewed transaction record and database. Saw no user-facing changes but a far more compact database representation.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13051

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

+50 -3
+25 -1
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 999 999 $xaction->setPHID($xaction->generatePHID()); 1000 1000 $comment_editor->applyEdit($xaction, $xaction->getComment()); 1001 1001 } else { 1002 - $xaction->save(); 1002 + 1003 + // TODO: This is a transitional hack to let us migrate edge 1004 + // transactions to a more efficient storage format. For now, we're 1005 + // going to write a new slim format to the database but keep the old 1006 + // bulky format on the objects so we don't have to upgrade all the 1007 + // edit logic to the new format yet. See T13051. 1008 + 1009 + $edge_type = PhabricatorTransactions::TYPE_EDGE; 1010 + if ($xaction->getTransactionType() == $edge_type) { 1011 + $bulky_old = $xaction->getOldValue(); 1012 + $bulky_new = $xaction->getNewValue(); 1013 + 1014 + $record = PhabricatorEdgeChangeRecord::newFromTransaction($xaction); 1015 + $slim_old = $record->getModernOldEdgeTransactionData(); 1016 + $slim_new = $record->getModernNewEdgeTransactionData(); 1017 + 1018 + $xaction->setOldValue($slim_old); 1019 + $xaction->setNewValue($slim_new); 1020 + $xaction->save(); 1021 + 1022 + $xaction->setOldValue($bulky_old); 1023 + $xaction->setNewValue($bulky_new); 1024 + } else { 1025 + $xaction->save(); 1026 + } 1003 1027 } 1004 1028 } 1005 1029
+25 -2
src/infrastructure/edges/util/PhabricatorEdgeChangeRecord.php
··· 44 44 return array_keys($rem); 45 45 } 46 46 47 + public function getModernOldEdgeTransactionData() { 48 + return $this->getRemovedPHIDs(); 49 + } 50 + 51 + public function getModernNewEdgeTransactionData() { 52 + return $this->getAddedPHIDs(); 53 + } 54 + 47 55 private function getOldDestinationPHIDs() { 48 56 if ($this->xaction) { 49 57 $old = $this->xaction->getOldValue(); 50 - return ipull($old, 'dst'); 58 + return $this->getPHIDsFromTransactionValue($old); 51 59 } 52 60 53 61 throw new Exception( ··· 57 65 private function getNewDestinationPHIDs() { 58 66 if ($this->xaction) { 59 67 $new = $this->xaction->getNewValue(); 60 - return ipull($new, 'dst'); 68 + return $this->getPHIDsFromTransactionValue($new); 61 69 } 62 70 63 71 throw new Exception( 64 72 pht('Edge change record is not configured with any change data.')); 65 73 } 66 74 75 + private function getPHIDsFromTransactionValue($value) { 76 + if (!$value) { 77 + return array(); 78 + } 79 + 80 + // If the list items are arrays, this is an older-style map of 81 + // dictionaries. 82 + $head = head($value); 83 + if (is_array($head)) { 84 + return ipull($value, 'dst'); 85 + } 86 + 87 + // If the list items are not arrays, this is a newer-style list of PHIDs. 88 + return $value; 89 + } 67 90 68 91 }