@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
at recaptime-dev/main 78 lines 2.3 kB view raw
1<?php 2 3final class DifferentialRevisionTimelineEngine 4 extends PhabricatorTimelineEngine { 5 6 protected function newTimelineView() { 7 $viewer = $this->getViewer(); 8 $xactions = $this->getTransactions(); 9 $revision = $this->getObject(); 10 11 $view_data = $this->getViewData(); 12 if (!$view_data) { 13 $view_data = array(); 14 } 15 16 $left = idx($view_data, 'left'); 17 $right = idx($view_data, 'right'); 18 19 $diffs = id(new DifferentialDiffQuery()) 20 ->setViewer($viewer) 21 ->withIDs(array($left, $right)) 22 ->execute(); 23 $diffs = mpull($diffs, null, 'getID'); 24 $left_diff = $diffs[$left]; 25 $right_diff = $diffs[$right]; 26 27 $old_ids = idx($view_data, 'old'); 28 $new_ids = idx($view_data, 'new'); 29 $old_ids = array_filter(explode(',', $old_ids)); 30 $new_ids = array_filter(explode(',', $new_ids)); 31 32 $type_inline = DifferentialTransaction::TYPE_INLINE; 33 $changeset_ids = array_merge($old_ids, $new_ids); 34 $inlines = array(); 35 foreach ($xactions as $xaction) { 36 if ($xaction->getTransactionType() == $type_inline) { 37 $inlines[] = $xaction->getComment(); 38 $changeset_ids[] = $xaction->getComment()->getChangesetID(); 39 } 40 } 41 42 if ($changeset_ids) { 43 $changesets = id(new DifferentialChangesetQuery()) 44 ->setViewer($viewer) 45 ->withIDs($changeset_ids) 46 ->execute(); 47 $changesets = mpull($changesets, null, 'getID'); 48 } else { 49 $changesets = array(); 50 } 51 52 foreach ($inlines as $key => $inline) { 53 $inlines[$key] = $inline->newInlineCommentObject(); 54 } 55 56 // NOTE: This is a bit sketchy: this method adjusts the inlines as a 57 // side effect, which means it will ultimately adjust the transaction 58 // comments and affect timeline rendering. 59 60 $old = array_select_keys($changesets, $old_ids); 61 $new = array_select_keys($changesets, $new_ids); 62 id(new PhabricatorInlineCommentAdjustmentEngine()) 63 ->setViewer($viewer) 64 ->setRevision($revision) 65 ->setOldChangesets($old) 66 ->setNewChangesets($new) 67 ->setInlines($inlines) 68 ->execute(); 69 70 return id(new DifferentialTransactionView()) 71 ->setViewData($view_data) 72 ->setChangesets($changesets) 73 ->setRevision($revision) 74 ->setLeftDiff($left_diff) 75 ->setRightDiff($right_diff); 76 } 77 78}