From 6c59db20a37927213ae20184c2c2bc369babedcc Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 7 May 2020 12:05:25 -0700 Subject: [PATCH] Replace "loadDraftComments()" with a Query Summary: Ref T13513. Take another step toward coherent query pathways for inlines. Test Plan: - Created, previewed, and submitted inlines in Diffusion. - Got a (mostly) appropriate draft state. - Got proper comment peristence, preview behavior, and submission behavior. Maniphest Tasks: T13513 Differential Revision: https://secure.phabricator.com/D21229 --- .../storage/PhabricatorAuditInlineComment.php | 21 ------------------- .../editor/DiffusionCommitEditEngine.php | 10 +++++---- .../engine/DiffusionCommitDraftEngine.php | 9 ++++---- 3 files changed, 11 insertions(+), 29 deletions(-) diff --git a/src/applications/audit/storage/PhabricatorAuditInlineComment.php b/src/applications/audit/storage/PhabricatorAuditInlineComment.php index f7686fcf0c..905694b24a 100644 --- a/src/applications/audit/storage/PhabricatorAuditInlineComment.php +++ b/src/applications/audit/storage/PhabricatorAuditInlineComment.php @@ -55,27 +55,6 @@ final class PhabricatorAuditInlineComment return head(self::buildProxies($inlines)); } - public static function loadDraftComments( - PhabricatorUser $viewer, - $commit_phid, - $raw = false) { - - $inlines = id(new DiffusionDiffInlineCommentQuery()) - ->setViewer($viewer) - ->withAuthorPHIDs(array($viewer->getPHID())) - ->withCommitPHIDs(array($commit_phid)) - ->withHasTransaction(false) - ->withIsDeleted(false) - ->needReplyToComments(true) - ->execute(); - - if ($raw) { - return $inlines; - } - - return self::buildProxies($inlines); - } - public static function loadPublishedComments( PhabricatorUser $viewer, $commit_phid) { diff --git a/src/applications/diffusion/editor/DiffusionCommitEditEngine.php b/src/applications/diffusion/editor/DiffusionCommitEditEngine.php index 6e45241d68..348a3e82c6 100644 --- a/src/applications/diffusion/editor/DiffusionCommitEditEngine.php +++ b/src/applications/diffusion/editor/DiffusionCommitEditEngine.php @@ -128,10 +128,12 @@ final class DiffusionCommitEditEngine $viewer = $this->getViewer(); $xactions = array(); - $inlines = PhabricatorAuditInlineComment::loadDraftComments( - $viewer, - $object->getPHID(), - $raw = true); + $inlines = id(new DiffusionDiffInlineCommentQuery()) + ->setViewer($viewer) + ->withObjectPHIDs(array($object->getPHID())) + ->withPublishableComments(true) + ->needReplyToComments(true) + ->execute(); $inlines = msort($inlines, 'getID'); $editor = $object->getApplicationTransactionEditor() diff --git a/src/applications/diffusion/engine/DiffusionCommitDraftEngine.php b/src/applications/diffusion/engine/DiffusionCommitDraftEngine.php index ce39e525a6..6245cf60fd 100644 --- a/src/applications/diffusion/engine/DiffusionCommitDraftEngine.php +++ b/src/applications/diffusion/engine/DiffusionCommitDraftEngine.php @@ -7,10 +7,11 @@ final class DiffusionCommitDraftEngine $viewer = $this->getViewer(); $commit = $this->getObject(); - $inlines = PhabricatorAuditInlineComment::loadDraftComments( - $viewer, - $commit->getPHID(), - $raw = true); + $inlines = id(new DiffusionDiffInlineCommentQuery()) + ->setViewer($viewer) + ->withCommitPHIDs(array($commit->getPHID())) + ->withPublishableComments(true) + ->execute(); return (bool)$inlines; }