From 4d1709651e4e50fede5c68f4e3477330babcdb20 Mon Sep 17 00:00:00 2001 From: Scott MacVicar Date: Mon, 14 Oct 2013 16:07:17 -0700 Subject: [PATCH] [releeph] Conduit failure with bad IDs Summary: Instead of returning a blank result it throws exceptions. Fix this up a little so we get some consistency with differential Test Plan: Loaded a bad phid for releeph, returns empty list. Try a good phid and get 2 releeph merges. Reviewers: epriestley, elenaperezrioja, dschleimer, #blessed_reviewers Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D7302 --- ...onduitAPI_releeph_queryrequests_Method.php | 3 ++ .../releeph/query/ReleephRequestQuery.php | 44 ++++++++++++------- .../releeph/storage/ReleephRequest.php | 9 +++- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/applications/releeph/conduit/ConduitAPI_releeph_queryrequests_Method.php b/src/applications/releeph/conduit/ConduitAPI_releeph_queryrequests_Method.php index 3eccb6a214..7180166efb 100644 --- a/src/applications/releeph/conduit/ConduitAPI_releeph_queryrequests_Method.php +++ b/src/applications/releeph/conduit/ConduitAPI_releeph_queryrequests_Method.php @@ -46,6 +46,9 @@ final class ConduitAPI_releeph_queryrequests_Method foreach ($releephRequests as $releephRequest) { $branch = $releephRequest->loadReleephBranch(); + if (!$branch) { + continue; + } $request_commit_phid = $releephRequest->getRequestCommitPHID(); $revisionPHID = $query->getRevisionPHID($request_commit_phid); diff --git a/src/applications/releeph/query/ReleephRequestQuery.php b/src/applications/releeph/query/ReleephRequestQuery.php index b57bc7a79b..560f7898fc 100644 --- a/src/applications/releeph/query/ReleephRequestQuery.php +++ b/src/applications/releeph/query/ReleephRequestQuery.php @@ -10,6 +10,7 @@ final class ReleephRequestQuery private $severities; private $requestorPHIDs; private $branchIDs; + private $revisionPHIDs; const STATUS_ALL = 'status-all'; const STATUS_OPEN = 'status-open'; @@ -67,22 +68,8 @@ final class ReleephRequestQuery } public function withRevisionPHIDs(array $revision_phids) { - $type = PhabricatorEdgeConfig::TYPE_DREV_HAS_COMMIT; - - $edges = id(new PhabricatorEdgeQuery()) - ->withSourcePHIDs($revision_phids) - ->withEdgeTypes(array($type)) - ->execute(); - - $this->commitToRevMap = array(); - - foreach ($edges as $revision_phid => $edge) { - foreach ($edge[$type] as $commitPHID => $item) { - $this->commitToRevMap[$commitPHID] = $revision_phid; - } - } - - $this->requestedCommitPHIDs = array_keys($this->commitToRevMap); + $this->revisionPHIDs = $revision_phids; + return $this; } public function loadPage() { @@ -172,6 +159,31 @@ final class ReleephRequestQuery $this->requestorPHIDs); } + if ($this->revisionPHIDs) { + $type = PhabricatorEdgeConfig::TYPE_DREV_HAS_COMMIT; + + $edges = id(new PhabricatorEdgeQuery()) + ->withSourcePHIDs($this->revisionPHIDs) + ->withEdgeTypes(array($type)) + ->execute(); + + $this->commitToRevMap = array(); + foreach ($edges as $revision_phid => $edge) { + foreach ($edge[$type] as $commitPHID => $item) { + $this->commitToRevMap[$commitPHID] = $revision_phid; + } + } + + if (!$this->commitToRevMap) { + throw new PhabricatorEmptyQueryException("Malformed Revision Phids"); + } + + $where[] = qsprintf( + $conn_r, + 'requestCommitPHID IN (%Ls)', + array_keys($this->commitToRevMap)); + } + $where[] = $this->buildPagingClause($conn_r); return $this->formatWhereClause($where); diff --git a/src/applications/releeph/storage/ReleephRequest.php b/src/applications/releeph/storage/ReleephRequest.php index a46e365aa2..932b2b64ea 100644 --- a/src/applications/releeph/storage/ReleephRequest.php +++ b/src/applications/releeph/storage/ReleephRequest.php @@ -55,6 +55,10 @@ final class ReleephRequest extends ReleephDAO */ public function getPusherIntent() { $project = $this->loadReleephProject(); + if (!$project) { + return null; + } + if (!$project->getPushers()) { return self::INTENT_WANT; } @@ -228,7 +232,10 @@ final class ReleephRequest extends ReleephDAO } public function loadReleephProject() { - return $this->loadReleephBranch()->loadReleephProject(); + $branch = $this->loadReleephBranch(); + if ($branch) { + return $branch->loadReleephProject(); + } } public function loadPhabricatorRepositoryCommit() {