From 83e0380046c77c830550ecf5deb2ad9118d15cf4 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Mon, 2 Sep 2013 13:24:41 -0700 Subject: [PATCH] Maniphest - fix fatal in custom query for users with no projects Summary: See https://github.com/facebook/phabricator/issues/380 for report. Test Plan: Maniphest -> Custom Query -> Put user with no project in "Any User Projects" field -> Search : observe no fatal Reviewers: epriestley Reviewed By: epriestley CC: Korvin, aran Differential Revision: https://secure.phabricator.com/D6862 --- .../maniphest/ManiphestTaskQuery.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/applications/maniphest/ManiphestTaskQuery.php b/src/applications/maniphest/ManiphestTaskQuery.php index 547b3706a1..9f0703a8f2 100644 --- a/src/applications/maniphest/ManiphestTaskQuery.php +++ b/src/applications/maniphest/ManiphestTaskQuery.php @@ -201,8 +201,26 @@ final class ManiphestTaskQuery extends PhabricatorQuery { return $this; } + /** + * This is a wrapper until we finish T603. The newer query class this class + * will inherit from handles catching this exception already. + */ public function execute() { + try { + $result = $this->executeManiphestQuery(); + } catch (PhabricatorEmptyQueryException $ex) { + $result = array(); + if ($this->calculateRows) { + $this->rowCount = 0; + } + } + + return $result; + } + + private function executeManiphestQuery() { + $task_dao = new ManiphestTask(); $conn = $task_dao->establishConnection('r'); @@ -505,6 +523,9 @@ final class ManiphestTaskQuery extends PhabricatorQuery { ->withMemberPHIDs($this->anyUserProjectPHIDs) ->execute(); $any_user_project_phids = mpull($projects, 'getPHID'); + if (!$any_user_project_phids) { + throw new PhabricatorEmptyQueryException(); + } return qsprintf( $conn,