Page MenuHomePhabricator

D8200.id.diff
No OneTemporary

D8200.id.diff

Index: src/applications/differential/editor/DifferentialRevisionEditor.php
===================================================================
--- src/applications/differential/editor/DifferentialRevisionEditor.php
+++ src/applications/differential/editor/DifferentialRevisionEditor.php
@@ -786,21 +786,29 @@
private function createComment() {
- $comment = id(new DifferentialComment())
+ $template = id(new DifferentialComment())
->setAuthorPHID($this->getActorPHID())
- ->setRevision($this->revision)
- ->setContent($this->getComments())
+ ->setRevision($this->revision);
+ if ($this->contentSource) {
+ $template->setContentSource($this->contentSource);
+ }
+
+ // Write the "update active diff" transaction.
+ id(clone $template)
->setAction(DifferentialAction::ACTION_UPDATE)
->setMetadata(
array(
DifferentialComment::METADATA_DIFF_ID => $this->getDiff()->getID(),
- ));
+ ))
+ ->save();
- if ($this->contentSource) {
- $comment->setContentSource($this->contentSource);
+ // If we have a comment, write the "add a comment" transaction.
+ if (strlen($this->getComments())) {
+ id(clone $template)
+ ->setAction(DifferentialAction::ACTION_COMMENT)
+ ->setContent($this->getComments())
+ ->save();
}
-
- $comment->save();
}
private function updateAuxiliaryFields() {
Index: src/applications/differential/storage/DifferentialComment.php
===================================================================
--- src/applications/differential/storage/DifferentialComment.php
+++ src/applications/differential/storage/DifferentialComment.php
@@ -127,24 +127,27 @@
$this->openTransaction();
$result = parent::save();
- $content_source = PhabricatorContentSource::newForSource(
- PhabricatorContentSource::SOURCE_LEGACY,
- array());
-
- $xaction_phid = PhabricatorPHID::generateNewPHID(
- PhabricatorApplicationTransactionPHIDTypeTransaction::TYPECONST,
- DifferentialPHIDTypeRevision::TYPECONST);
-
- $proxy = $this->getProxyComment();
- $proxy
- ->setAuthorPHID($this->getAuthorPHID())
- ->setViewPolicy('public')
- ->setEditPolicy($this->getAuthorPHID())
- ->setContentSource($content_source)
- ->setCommentVersion(1)
- ->setLegacyCommentID($this->getID())
- ->setTransactionPHID($xaction_phid)
- ->save();
+ if (strlen($this->getContent())) {
+ $content_source = PhabricatorContentSource::newForSource(
+ PhabricatorContentSource::SOURCE_LEGACY,
+ array());
+
+ $xaction_phid = PhabricatorPHID::generateNewPHID(
+ PhabricatorApplicationTransactionPHIDTypeTransaction::TYPECONST,
+ DifferentialPHIDTypeRevision::TYPECONST);
+
+ $proxy = $this->getProxyComment();
+ $proxy
+ ->setAuthorPHID($this->getAuthorPHID())
+ ->setViewPolicy('public')
+ ->setEditPolicy($this->getAuthorPHID())
+ ->setContentSource($content_source)
+ ->setCommentVersion(1)
+ ->setLegacyCommentID($this->getID())
+ ->setTransactionPHID($xaction_phid)
+ ->save();
+ }
+
$this->saveTransaction();
return $result;

File Metadata

Mime Type
text/plain
Expires
Oct 19 2024, 11:37 AM (4 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6723349
Default Alt Text
D8200.id.diff (3 KB)

Event Timeline