From 983d77848b4c7d3b27e5a61c347fbe900aa4707d Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 7 May 2020 13:02:06 -0700 Subject: [PATCH] Move the "Inline List" view to "DiffInlineCommentQuery" Summary: Ref T13513. Continue removing usage sites for the obsolete "DifferentialInlineCommentQuery". Test Plan: Viewed the inline list in Differential, saw sensible inlines. Maniphest Tasks: T13513 Differential Revision: https://secure.phabricator.com/D21232 --- .../DifferentialRevisionInlinesController.php | 9 ++--- .../controller/DiffusionCommitController.php | 3 +- .../controller/DiffusionDiffController.php | 3 +- .../PhabricatorDiffInlineCommentQuery.php | 34 +++++++++---------- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/applications/differential/controller/DifferentialRevisionInlinesController.php b/src/applications/differential/controller/DifferentialRevisionInlinesController.php index 735b9e8af9..da96fed069 100644 --- a/src/applications/differential/controller/DifferentialRevisionInlinesController.php +++ b/src/applications/differential/controller/DifferentialRevisionInlinesController.php @@ -24,11 +24,12 @@ final class DifferentialRevisionInlinesController $revision_uri = $revision->getURI(); $revision_title = $revision->getTitle(); - $query = id(new DifferentialInlineCommentQuery()) + $inlines = id(new DifferentialDiffInlineCommentQuery()) ->setViewer($viewer) - ->needHidden(true) - ->withRevisionPHIDs(array($revision->getPHID())); - $inlines = $query->execute(); + ->withRevisionPHIDs(array($revision->getPHID())) + ->withPublishedComments(true) + ->execute(); + $inlines = mpull($inlines, 'newInlineCommentObject'); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($revision_monogram, $revision_uri); diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index c1858b3422..e069fb7779 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -418,7 +418,8 @@ final class DiffusionCommitController extends DiffusionController { $inlines = id(new DiffusionDiffInlineCommentQuery()) ->setViewer($viewer) ->withCommitPHIDs(array($commit->getPHID())) - ->withVisibleComments(true) + ->withPublishedComments(true) + ->withPublishableComments(true) ->execute(); $inlines = mpull($inlines, 'newInlineCommentObject'); diff --git a/src/applications/diffusion/controller/DiffusionDiffController.php b/src/applications/diffusion/controller/DiffusionDiffController.php index 51d815db0c..69a473dc91 100644 --- a/src/applications/diffusion/controller/DiffusionDiffController.php +++ b/src/applications/diffusion/controller/DiffusionDiffController.php @@ -103,7 +103,8 @@ final class DiffusionDiffController extends DiffusionController { ->setViewer($viewer) ->withCommitPHIDs(array($commit->getPHID())) ->withPathIDs(array($path_id)) - ->withVisibleComments(true) + ->withPublishedComments(true) + ->withPublishableComments(true) ->execute(); $inlines = mpull($inlines, 'newInlineCommentObject'); diff --git a/src/infrastructure/diff/query/PhabricatorDiffInlineCommentQuery.php b/src/infrastructure/diff/query/PhabricatorDiffInlineCommentQuery.php index e978bd5614..b523fe0011 100644 --- a/src/infrastructure/diff/query/PhabricatorDiffInlineCommentQuery.php +++ b/src/infrastructure/diff/query/PhabricatorDiffInlineCommentQuery.php @@ -5,7 +5,7 @@ abstract class PhabricatorDiffInlineCommentQuery private $fixedStates; private $needReplyToComments; - private $visibleComments; + private $publishedComments; private $publishableComments; abstract protected function buildInlineCommentWhereClauseParts( @@ -22,13 +22,13 @@ abstract class PhabricatorDiffInlineCommentQuery return $this; } - public function withVisibleComments($with_visible) { - $this->visibleComments = $with_visible; + public function withPublishableComments($with_publishable) { + $this->publishableComments = $with_publishable; return $this; } - public function withPublishableComments($with_publishable) { - $this->publishableComments = $with_publishable; + public function withPublishedComments($with_published) { + $this->publishedComments = $with_published; return $this; } @@ -51,32 +51,30 @@ abstract class PhabricatorDiffInlineCommentQuery $show_published = false; $show_publishable = false; - if ($this->visibleComments !== null) { - if (!$this->visibleComments) { - throw new Exception( - pht( - 'Querying for comments that are not visible is '. - 'not supported.')); - } - $show_published = true; - $show_publishable = true; - } - if ($this->publishableComments !== null) { if (!$this->publishableComments) { throw new Exception( pht( - 'Querying for comments that are not publishable is '. + 'Querying for comments that are "not publishable" is '. 'not supported.')); } $show_publishable = true; } + if ($this->publishedComments !== null) { + if (!$this->publishedComments) { + throw new Exception( + pht( + 'Querying for comments that are "not published" is '. + 'not supported.')); + } + $show_published = true; + } + if ($show_publishable || $show_published) { $clauses = array(); if ($show_published) { - // Published comments are always visible. $clauses[] = qsprintf( $conn, '%T.transactionPHID IS NOT NULL',