diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php --- a/src/applications/differential/controller/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/DifferentialRevisionViewController.php @@ -96,9 +96,7 @@ $props = mpull($props, 'getData', 'getName'); $all_changesets = $changesets; - $inlines = $this->loadInlineComments( - $revision, - $all_changesets); + $inlines = $revision->loadInlineComments($all_changesets); $object_phids = array_merge( $revision->getReviewers(), @@ -644,44 +642,6 @@ return $actions_dict; } - private function loadInlineComments( - DifferentialRevision $revision, - array &$changesets) { - assert_instances_of($changesets, 'DifferentialChangeset'); - - $inline_comments = array(); - - $inline_comments = id(new DifferentialInlineCommentQuery()) - ->withRevisionIDs(array($revision->getID())) - ->withNotDraft(true) - ->execute(); - - $load_changesets = array(); - foreach ($inline_comments as $inline) { - $changeset_id = $inline->getChangesetID(); - if (isset($changesets[$changeset_id])) { - continue; - } - $load_changesets[$changeset_id] = true; - } - - $more_changesets = array(); - if ($load_changesets) { - $changeset_ids = array_keys($load_changesets); - $more_changesets += id(new DifferentialChangeset()) - ->loadAllWhere( - 'id IN (%Ld)', - $changeset_ids); - } - - if ($more_changesets) { - $changesets += $more_changesets; - $changesets = msort($changesets, 'getSortKey'); - } - - return $inline_comments; - } - private function loadChangesetsAndVsMap( DifferentialDiff $target, DifferentialDiff $diff_vs = null, diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php --- a/src/applications/differential/storage/DifferentialRevision.php +++ b/src/applications/differential/storage/DifferentialRevision.php @@ -280,6 +280,44 @@ return $this; } + public function loadInlineComments( + array &$changesets) { + assert_instances_of($changesets, 'DifferentialChangeset'); + + $inline_comments = array(); + + $inline_comments = id(new DifferentialInlineCommentQuery()) + ->withRevisionIDs(array($this->getID())) + ->withNotDraft(true) + ->execute(); + + $load_changesets = array(); + foreach ($inline_comments as $inline) { + $changeset_id = $inline->getChangesetID(); + if (isset($changesets[$changeset_id])) { + continue; + } + $load_changesets[$changeset_id] = true; + } + + $more_changesets = array(); + if ($load_changesets) { + $changeset_ids = array_keys($load_changesets); + $more_changesets += id(new DifferentialChangeset()) + ->loadAllWhere( + 'id IN (%Ld)', + $changeset_ids); + } + + if ($more_changesets) { + $changesets += $more_changesets; + $changesets = msort($changesets, 'getSortKey'); + } + + return $inline_comments; + } + + public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, @@ -495,6 +533,9 @@ ->setViewer($request->getUser()) ->withDiffs(array($right_diff)) ->execute(); + // NOTE: this mutates $changesets to include changesets for all inline + // comments...! + $inlines = $this->loadInlineComments($changesets); $changesets = mpull($changesets, null, 'getID'); return $timeline