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

Fix an issue when undoing mutiple inline comment deletions

Summary:
Ref T13559. If you create comments A and B, then delete comments A and B, then undo the deletion of A, the UI undoes the deletion of B instead.

This is becasue the undo rows are shipped down with a static scalar metadata reference. When copied multiple times to create multiple undo rows, they reference the same data object.

Preventing this in the general case is a problem with greater scope. For now, just avoid rendering these rows with any metadata so they don't alias a single data object.

Test Plan:
- Created comments A, B.
- Deleted comments A, B.
- Clicked "Undo" on A.
- Before: Deletion of "B" undone.
- After: Deletion of "A" undone.

Maniphest Tasks: T13559

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

+35 -7
+3
src/applications/differential/render/DifferentialChangesetRenderer.php
··· 718 718 719 719 foreach ($views as $key => $view) { 720 720 $scaffold = $this->getRowScaffoldForInline($view); 721 + 722 + $scaffold->setIsUndoTemplate(true); 723 + 721 724 $views[$key] = id(new PHUIDiffInlineCommentTableScaffold()) 722 725 ->addRowScaffold($scaffold); 723 726 }
+31 -6
src/infrastructure/diff/view/PHUIDiffInlineCommentRowScaffold.php
··· 10 10 abstract class PHUIDiffInlineCommentRowScaffold extends AphrontView { 11 11 12 12 private $views = array(); 13 + private $isUndoTemplate; 14 + 15 + final public function setIsUndoTemplate($is_undo_template) { 16 + $this->isUndoTemplate = $is_undo_template; 17 + return $this; 18 + } 19 + 20 + final public function getIsUndoTemplate() { 21 + return $this->isUndoTemplate; 22 + } 13 23 14 24 public function getInlineViews() { 15 25 return $this->views; ··· 21 31 } 22 32 23 33 protected function getRowAttributes() { 34 + $is_undo_template = $this->getIsUndoTemplate(); 35 + 24 36 $is_hidden = false; 25 - foreach ($this->getInlineViews() as $view) { 26 - if ($view->isHidden()) { 27 - $is_hidden = true; 37 + if ($is_undo_template) { 38 + 39 + // NOTE: When this scaffold is turned into an "undo" template, it is 40 + // important it not have any metadata: the metadata reference will be 41 + // copied to each instance of the row. This is a complicated mess; for 42 + // now, just sneak by without generating metadata when rendering undo 43 + // templates. 44 + 45 + $metadata = null; 46 + } else { 47 + foreach ($this->getInlineViews() as $view) { 48 + if ($view->isHidden()) { 49 + $is_hidden = true; 50 + } 28 51 } 52 + 53 + $metadata = array( 54 + 'hidden' => $is_hidden, 55 + ); 29 56 } 30 57 31 58 $classes = array(); ··· 37 64 $result = array( 38 65 'class' => implode(' ', $classes), 39 66 'sigil' => 'inline-row', 40 - 'meta' => array( 41 - 'hidden' => $is_hidden, 42 - ), 67 + 'meta' => $metadata, 43 68 ); 44 69 45 70 return $result;
+1 -1
src/infrastructure/diff/view/PHUIDiffInlineCommentUndoView.php
··· 27 27 array( 28 28 'class' => 'differential-inline-undo', 29 29 ), 30 - array(pht('Changes discarded. '), $link)); 30 + array(pht('Changes discarded.'), ' ', $link)); 31 31 } 32 32 33 33 }