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

Order inline comments in Diffusion consistently with Differential

Summary:
Fixes T8739. Currently, Diffusion inline comments in the timeline are sorted arbitrarily, mostly by creation order.

Instead, sort them by line number, like Differential.

Test Plan:
Made comments in "C", "B", "A" order, saw them in line order after submit:

{F2343032}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8739

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

+45 -35
+45 -35
src/applications/audit/view/PhabricatorAuditTransactionView.php
··· 81 81 } 82 82 } 83 83 84 - if ($inlines) { 85 - 86 - // TODO: This should do something similar to sortAndGroupInlines() to get 87 - // a stable ordering. 84 + $structs = array(); 85 + foreach ($inlines as $key => $inline) { 86 + $comment = $inline->getComment(); 87 + if (!$comment) { 88 + // TODO: Migrate these away? They probably do not exist on normal 89 + // non-development installs. 90 + unset($inlines[$key]); 91 + continue; 92 + } 88 93 89 - $inlines_by_path = array(); 90 - foreach ($inlines as $key => $inline) { 91 - $comment = $inline->getComment(); 92 - if (!$comment) { 93 - // TODO: Migrate these away? They probably do not exist on normal 94 - // non-development installs. 95 - unset($inlines[$key]); 96 - continue; 97 - } 98 - $path_id = $comment->getPathID(); 99 - $inlines_by_path[$path_id][] = $inline; 94 + $path_id = $comment->getPathID(); 95 + $path = idx($this->pathMap, $path_id); 96 + if ($path === null) { 97 + continue; 100 98 } 101 99 102 - $inline_view = new PhabricatorInlineSummaryView(); 103 - foreach ($inlines_by_path as $path_id => $group) { 104 - $path = idx($this->pathMap, $path_id); 105 - if ($path === null) { 106 - continue; 107 - } 100 + $structs[] = array( 101 + 'inline' => $inline, 102 + 'path' => $path, 103 + 'sort' => (string)id(new PhutilSortVector()) 104 + ->addString($path) 105 + ->addInt($comment->getLineNumber()) 106 + ->addInt($comment->getLineLength()) 107 + ->addInt($inline->getID()), 108 + ); 109 + } 108 110 109 - $items = array(); 110 - foreach ($group as $inline) { 111 - $comment = $inline->getComment(); 112 - $item = array( 113 - 'id' => $comment->getID(), 114 - 'line' => $comment->getLineNumber(), 115 - 'length' => $comment->getLineLength(), 116 - 'content' => parent::renderTransactionContent($inline), 117 - ); 118 - $items[] = $item; 119 - } 120 - $inline_view->addCommentGroup($path, $items); 121 - } 111 + if (!$structs) { 112 + return $out; 113 + } 122 114 123 - $out[] = $inline_view; 115 + $structs = isort($structs, 'sort'); 116 + $structs = igroup($structs, 'path'); 117 + 118 + $inline_view = new PhabricatorInlineSummaryView(); 119 + foreach ($structs as $path => $group) { 120 + $inlines = ipull($group, 'inline'); 121 + $items = array(); 122 + foreach ($inlines as $inline) { 123 + $comment = $inline->getComment(); 124 + $items[] = array( 125 + 'id' => $comment->getID(), 126 + 'line' => $comment->getLineNumber(), 127 + 'length' => $comment->getLineLength(), 128 + 'content' => parent::renderTransactionContent($inline), 129 + ); 130 + } 131 + $inline_view->addCommentGroup($path, $items); 124 132 } 133 + 134 + $out[] = $inline_view; 125 135 126 136 return $out; 127 137 }