From 949b9163d006854fb88cd4dc3902fca724b7859b Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 7 May 2020 12:22:29 -0700 Subject: [PATCH] Replace remaining pseudo-query methods on AuditInlineComment Summary: Ref T13513. Another step closer to the light. Test Plan: Created, edited, deleted, replied to, and submitted inline comments in Diffusion. Maniphest Tasks: T13513 Differential Revision: https://secure.phabricator.com/D21230 --- .../storage/PhabricatorAuditInlineComment.php | 43 ------------------- .../DiffusionInlineCommentController.php | 24 ++++++++++- 2 files changed, 22 insertions(+), 45 deletions(-) diff --git a/src/applications/audit/storage/PhabricatorAuditInlineComment.php b/src/applications/audit/storage/PhabricatorAuditInlineComment.php index 905694b24a..0a3a0400cf 100644 --- a/src/applications/audit/storage/PhabricatorAuditInlineComment.php +++ b/src/applications/audit/storage/PhabricatorAuditInlineComment.php @@ -34,49 +34,6 @@ final class PhabricatorAuditInlineComment return $this->getStorageObject(); } - public static function loadID($id) { - $inlines = id(new PhabricatorAuditTransactionComment())->loadAllWhere( - 'id = %d', - $id); - if (!$inlines) { - return null; - } - - return head(self::buildProxies($inlines)); - } - - public static function loadPHID($phid) { - $inlines = id(new PhabricatorAuditTransactionComment())->loadAllWhere( - 'phid = %s', - $phid); - if (!$inlines) { - return null; - } - return head(self::buildProxies($inlines)); - } - - public static function loadPublishedComments( - PhabricatorUser $viewer, - $commit_phid) { - - $inlines = id(new DiffusionDiffInlineCommentQuery()) - ->setViewer($viewer) - ->withCommitPHIDs(array($commit_phid)) - ->withHasTransaction(true) - ->execute(); - - return self::buildProxies($inlines); - } - - private static function buildProxies(array $inlines) { - $results = array(); - foreach ($inlines as $key => $inline) { - $results[$key] = self::newFromModernComment( - $inline); - } - return $results; - } - public static function newFromModernComment( PhabricatorAuditTransactionComment $comment) { diff --git a/src/applications/diffusion/controller/DiffusionInlineCommentController.php b/src/applications/diffusion/controller/DiffusionInlineCommentController.php index 33e2903799..9d9538ecd7 100644 --- a/src/applications/diffusion/controller/DiffusionInlineCommentController.php +++ b/src/applications/diffusion/controller/DiffusionInlineCommentController.php @@ -42,11 +42,31 @@ final class DiffusionInlineCommentController } protected function loadComment($id) { - return PhabricatorAuditInlineComment::loadID($id); + $viewer = $this->getViewer(); + $inline = id(new DiffusionDiffInlineCommentQuery()) + ->setViewer($viewer) + ->withIDs(array($id)) + ->executeOne(); + + if ($inline) { + $inline = $inline->newInlineCommentObject(); + } + + return $inline; } protected function loadCommentByPHID($phid) { - return PhabricatorAuditInlineComment::loadPHID($phid); + $viewer = $this->getViewer(); + $inline = id(new DiffusionDiffInlineCommentQuery()) + ->setViewer($viewer) + ->withPHIDs(array($phid)) + ->executeOne(); + + if ($inline) { + $inline = $inline->newInlineCommentObject(); + } + + return $inline; } protected function loadCommentForEdit($id) {