mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 23:31:03 +01: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:
parent
b1dfbda741
commit
a025050e87
2 changed files with 17 additions and 12 deletions
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue