1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

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
This commit is contained in:
Bob Trahan 2014-12-02 17:03:04 -08:00
parent 69cc5df645
commit 798be00fc3
2 changed files with 42 additions and 2 deletions

View file

@ -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;
}

View file

@ -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) {