Skip to content

Commit 798be00

Browse files
committed
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
1 parent 69cc5df commit 798be00

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

src/applications/transactions/editor/PhabricatorApplicationTransactionCommentEditor.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,26 @@ public function applyEdit(
6969
$xaction->setViewPolicy($comment->getViewPolicy());
7070
$xaction->setEditPolicy($comment->getEditPolicy());
7171
$xaction->save();
72-
72+
$xaction->attachComment($comment);
73+
74+
$object = id(new PhabricatorObjectQuery())
75+
->withPHIDs(array($xaction->getObjectPHID()))
76+
->setViewer($this->getActor())
77+
->executeOne();
78+
if ($object &&
79+
$object instanceof PhabricatorApplicationTransactionInterface) {
80+
$editor = $object->getApplicationTransactionEditor();
81+
$editor->setActor($this->getActor());
82+
$support_xactions = $editor->getExpandedSupportTransactions(
83+
$object,
84+
$xaction);
85+
if ($support_xactions) {
86+
$editor
87+
->setContentSource($this->getContentSource())
88+
->setContinueOnNoEffect(true)
89+
->applyTransactions($object, $support_xactions);
90+
}
91+
}
7392
$xaction->endReadLocking();
7493
$xaction->saveTransaction();
7594

@@ -85,8 +104,6 @@ public function applyEdit(
85104
$editor->save();
86105
}
87106

88-
$xaction->attachComment($comment);
89-
90107
return $this;
91108
}
92109

src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,29 @@ protected function expandTransaction(
11171117
}
11181118

11191119

1120+
public function getExpandedSupportTransactions(
1121+
PhabricatorLiskDAO $object,
1122+
PhabricatorApplicationTransaction $xaction) {
1123+
1124+
$xactions = array($xaction);
1125+
$xactions = $this->expandSupportTransactions(
1126+
$object,
1127+
$xactions);
1128+
1129+
if (count($xactions) == 1) {
1130+
return array();
1131+
}
1132+
1133+
foreach ($xactions as $index => $cxaction) {
1134+
if ($cxaction === $xaction) {
1135+
unset($xactions[$index]);
1136+
break;
1137+
}
1138+
}
1139+
1140+
return $xactions;
1141+
}
1142+
11201143
private function expandSupportTransactions(
11211144
PhabricatorLiskDAO $object,
11221145
array $xactions) {

0 commit comments

Comments
 (0)