1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-30 09:20:58 +01:00

[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
This commit is contained in:
Scott MacVicar 2013-10-14 16:07:17 -07:00
parent c4abf160cc
commit 4d1709651e
3 changed files with 39 additions and 17 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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() {