From dfc3506240ebc188e7c45e7ba64e51b8291eee28 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 16 Dec 2011 13:26:18 -0800 Subject: [PATCH] Prevent "Maniphest Tasks" field from creating empty comment when revisions are updated Summary: - If you update a revision with a nonempty "Maniphest Tasks" field, an empty comment is posted (see T586). - The transaction email currently says "Attached revision 'Unknown Differential Revision'", move attaching to "didWriteRevision()" to make sure the object has been written. Test Plan: - Attached; updated a revision. Reviewers: btrahan, jungejason Reviewed By: btrahan CC: aran, btrahan Maniphest Tasks: T685 Differential Revision: 1223 --- .../DifferentialManiphestTasksFieldSpecification.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/applications/differential/field/specification/maniphesttasks/DifferentialManiphestTasksFieldSpecification.php b/src/applications/differential/field/specification/maniphesttasks/DifferentialManiphestTasksFieldSpecification.php index 45228ef94d..d262957660 100644 --- a/src/applications/differential/field/specification/maniphesttasks/DifferentialManiphestTasksFieldSpecification.php +++ b/src/applications/differential/field/specification/maniphesttasks/DifferentialManiphestTasksFieldSpecification.php @@ -58,7 +58,7 @@ final class DifferentialManiphestTasksFieldSpecification * * @return void */ - public function willWriteRevision(DifferentialRevisionEditor $editor) { + public function didWriteRevision(DifferentialRevisionEditor $editor) { // 1 -- revision => tasks $revision = $editor->getRevision(); $revision->setAttachedPHIDs(PhabricatorPHIDConstants::PHID_TYPE_TASK, @@ -86,6 +86,11 @@ final class DifferentialManiphestTasksFieldSpecification if (empty($new[$attach_type])) { $new[$attach_type] = array(); } + if (array_key_exists($revision->getPHID(), $new[$attach_type])) { + // Already attached, just skip the update. + continue; + } + $new[$attach_type][$revision->getPHID()] = array(); $transaction->setNewValue($new);