From bc4f86d2799681b8e96702d0671245c85ee8215b Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 19 Oct 2020 12:21:06 -0700 Subject: [PATCH] When a new, deleted, draft inline is revived with "Undo", undelete it Summary: See PHI1876. Normally, deleted inlines are undeleted with an "undelete" operation, which clears the "isDeleted" flag. However, when an inline is deleted implicitly by using "Cancel" without first saving it, the flag currently isn't cleared properly. This can lead to cases where inlines seem to vanish (they are shown to the user in the UI, but treated as deleted on submission). Test Plan: There are two affected sequences here: - Create a new inline, type text, cancel, undo. - Create a new inline, type text, cancel, undo, save. The former sequence triggers an "edit" operation. The subsequent "Save" in the second sequence triggers a "save" operation. It's normally impossible in the UI to execute a "save" without executing an "edit" first, but "save" clearly should undelete the comment if you get there somehow, so this change clears the deleted flag in both cases for completeness. - Executed both sequences, saw comment persist in preview, on reload, and after submission. Differential Revision: https://secure.phabricator.com/D21483 --- .../diff/PhabricatorInlineCommentController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/diff/PhabricatorInlineCommentController.php b/src/infrastructure/diff/PhabricatorInlineCommentController.php index e1b8dc7264..693f66066f 100644 --- a/src/infrastructure/diff/PhabricatorInlineCommentController.php +++ b/src/infrastructure/diff/PhabricatorInlineCommentController.php @@ -189,6 +189,8 @@ abstract class PhabricatorInlineCommentController $inline->setIsEditing(false); if (!$inline->isVoidComment($viewer)) { + $inline->setIsDeleted(0); + $this->saveComment($inline); return $this->buildRenderedCommentResponse( @@ -217,7 +219,10 @@ abstract class PhabricatorInlineCommentController $is_dirty = false; if (!$inline->getIsEditing()) { - $inline->setIsEditing(true); + $inline + ->setIsDeleted(0) + ->setIsEditing(true); + $is_dirty = true; }