1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

When adding {Fnnn} file references by editing comments, link objects to files

Summary: Fixes T6037. We don't currently write the "this file is attached to such-and-such object" edge on comment edits.

Test Plan: Edited a comment, adding `{Fnnn}`. Verified file was not attached before the edit, but was afterward.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6037

Differential Revision: https://secure.phabricator.com/D10423
This commit is contained in:
epriestley 2014-09-05 12:27:34 -07:00
parent af842600ce
commit 25f4a23a95

View file

@ -46,6 +46,12 @@ final class PhabricatorApplicationTransactionCommentEditor
$comment->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC); $comment->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC);
$comment->setEditPolicy($this->getActingAsPHID()); $comment->setEditPolicy($this->getActingAsPHID());
$file_phids = PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles(
$actor,
array(
$comment->getContent(),
));
$xaction->openTransaction(); $xaction->openTransaction();
$xaction->beginReadLocking(); $xaction->beginReadLocking();
if ($xaction->getID()) { if ($xaction->getID()) {
@ -67,10 +73,19 @@ final class PhabricatorApplicationTransactionCommentEditor
$xaction->endReadLocking(); $xaction->endReadLocking();
$xaction->saveTransaction(); $xaction->saveTransaction();
$xaction->attachComment($comment); // Add links to any files newly referenced by the edit.
if ($file_phids) {
$editor = new PhabricatorEdgeEditor();
foreach ($file_phids as $file_phid) {
$editor->addEdge(
$xaction->getObjectPHID(),
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE,
$file_phid);
}
$editor->save();
}
// TODO: Emit an event for notifications/feed? Can we handle them $xaction->attachComment($comment);
// generically?
return $this; return $this;
} }