1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Fix an issue with differential.getdiff when providing a revision ID

Summary:
If handed a revision ID, we might get more than one result, which causes `executeOne()` to throw. Instead, translate the revision id into a diff ID before querying for the diff.

Also one small consistency change to parameter casing.

Test Plan: Used console to query for a revision with more than one diff using the revision id.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, mbishopim3

Differential Revision: https://secure.phabricator.com/D7026
This commit is contained in:
epriestley 2013-09-18 15:31:48 -07:00
parent b1dfbda741
commit a025050e87
2 changed files with 17 additions and 12 deletions

View file

@ -43,23 +43,28 @@ final class ConduitAPI_differential_getdiff_Method
}
protected function execute(ConduitAPIRequest $request) {
$diff = null;
$revision_ids = array();
$diff_ids = array();
$diff_id = $request->getValue('diff_id');
// If we have a revision ID, we need the most recent diff. Figure that out
// without loading all the attached data.
$revision_id = $request->getValue('revision_id');
if ($revision_id) {
$revision_ids = array($revision_id);
$diffs = id(new DifferentialDiffQuery())
->setViewer($request->getUser())
->withRevisionIDs(array($revision_id))
->execute();
if ($diffs) {
$diff_id = head($diffs)->getID();
} else {
throw new ConduitException('ERR_BAD_DIFF');
}
$diff_id = $request->getValue('diff_id');
}
$diff = null;
if ($diff_id) {
$diff_ids = array($diff_id);
}
if ($diff_ids || $revision_ids) {
$diff = id(new DifferentialDiffQuery())
->setViewer($request->getUser())
->withIDs($diff_ids)
->withRevisionIDs($revision_ids)
->withIDs(array($diff_id))
->needChangesets(true)
->needArcanistProjects(true)
->executeOne();

View file

@ -13,7 +13,7 @@ final class ConduitAPI_differential_querydiffs_Method
public function defineParamTypes() {
return array(
'ids' => 'optional list<uint>',
'revison_ids' => 'optional list<uint>',
'revisonIDs' => 'optional list<uint>',
);
}
@ -27,7 +27,7 @@ final class ConduitAPI_differential_querydiffs_Method
protected function execute(ConduitAPIRequest $request) {
$ids = $request->getValue('ids', array());
$revision_ids = $request->getValue('revision_ids', array());
$revision_ids = $request->getValue('revisionIDs', array());
$diffs = array();
$diff_dicts = array();
if ($ids || $revision_ids) {