From f94cee8628883f17d49a868af6ba38b83d7a3fc1 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 25 Jun 2018 05:59:35 -0700 Subject: [PATCH] Fix querying for transactions over "transaction.search" when the object does not support comments Summary: See PHI725. Ref T13151. We currently try to load comments unconditionally, but not all objects (like projects) have comments. Only try to load comments if an object actually has comments. Test Plan: Queried for an object with no comments, like project `#masonry`, via `transaction.search`. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13151 Differential Revision: https://secure.phabricator.com/D19507 --- .../TransactionSearchConduitAPIMethod.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php b/src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php index 17f53cfeee..3b040ea2c3 100644 --- a/src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php +++ b/src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php @@ -85,22 +85,23 @@ final class TransactionSearchConduitAPIMethod $xactions = $xaction_query->executeWithCursorPager($pager); + $comment_map = array(); if ($xactions) { $template = head($xactions)->getApplicationTransactionCommentObject(); + if ($template) { - $query = new PhabricatorApplicationTransactionTemplatedCommentQuery(); + $query = new PhabricatorApplicationTransactionTemplatedCommentQuery(); - $comment_map = $query - ->setViewer($viewer) - ->setTemplate($template) - ->withTransactionPHIDs(mpull($xactions, 'getPHID')) - ->execute(); + $comment_map = $query + ->setViewer($viewer) + ->setTemplate($template) + ->withTransactionPHIDs(mpull($xactions, 'getPHID')) + ->execute(); - $comment_map = msort($comment_map, 'getCommentVersion'); - $comment_map = array_reverse($comment_map); - $comment_map = mgroup($comment_map, 'getTransactionPHID'); - } else { - $comment_map = array(); + $comment_map = msort($comment_map, 'getCommentVersion'); + $comment_map = array_reverse($comment_map); + $comment_map = mgroup($comment_map, 'getTransactionPHID'); + } } $modular_classes = array();