From 798be00fc3c74d6f2b1522e7e69b9e1ca6211cb9 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Tue, 2 Dec 2014 17:03:04 -0800 Subject: [PATCH] Transactions - make sure to do fancy remarkup stuff on edit too Summary: Fixes T6648. We do some automagical hotness based on the text you enter in remarkup textareas - e.g. adding projects or mentioning other objects. Refine the code here so that even when just editing a comment we build these transactions and apply them. Test Plan: edited a comment and noted new mentions and projects showed up appropriately...! Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6648 Differential Revision: https://secure.phabricator.com/D10922 --- ...torApplicationTransactionCommentEditor.php | 21 +++++++++++++++-- ...habricatorApplicationTransactionEditor.php | 23 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionCommentEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionCommentEditor.php index bca48b5c7c..2728e4cfed 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionCommentEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionCommentEditor.php @@ -69,7 +69,26 @@ final class PhabricatorApplicationTransactionCommentEditor $xaction->setViewPolicy($comment->getViewPolicy()); $xaction->setEditPolicy($comment->getEditPolicy()); $xaction->save(); + $xaction->attachComment($comment); + $object = id(new PhabricatorObjectQuery()) + ->withPHIDs(array($xaction->getObjectPHID())) + ->setViewer($this->getActor()) + ->executeOne(); + if ($object && + $object instanceof PhabricatorApplicationTransactionInterface) { + $editor = $object->getApplicationTransactionEditor(); + $editor->setActor($this->getActor()); + $support_xactions = $editor->getExpandedSupportTransactions( + $object, + $xaction); + if ($support_xactions) { + $editor + ->setContentSource($this->getContentSource()) + ->setContinueOnNoEffect(true) + ->applyTransactions($object, $support_xactions); + } + } $xaction->endReadLocking(); $xaction->saveTransaction(); @@ -85,8 +104,6 @@ final class PhabricatorApplicationTransactionCommentEditor $editor->save(); } - $xaction->attachComment($comment); - return $this; } diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index 0a1878318b..7e02c6a3c1 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -1117,6 +1117,29 @@ abstract class PhabricatorApplicationTransactionEditor } + public function getExpandedSupportTransactions( + PhabricatorLiskDAO $object, + PhabricatorApplicationTransaction $xaction) { + + $xactions = array($xaction); + $xactions = $this->expandSupportTransactions( + $object, + $xactions); + + if (count($xactions) == 1) { + return array(); + } + + foreach ($xactions as $index => $cxaction) { + if ($cxaction === $xaction) { + unset($xactions[$index]); + break; + } + } + + return $xactions; + } + private function expandSupportTransactions( PhabricatorLiskDAO $object, array $xactions) {