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
|
@ -43,23 +43,28 @@ final class ConduitAPI_differential_getdiff_Method
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(ConduitAPIRequest $request) {
|
protected function execute(ConduitAPIRequest $request) {
|
||||||
$diff = null;
|
$diff_id = $request->getValue('diff_id');
|
||||||
$revision_ids = array();
|
|
||||||
$diff_ids = array();
|
|
||||||
|
|
||||||
|
// 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');
|
$revision_id = $request->getValue('revision_id');
|
||||||
if ($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) {
|
if ($diff_id) {
|
||||||
$diff_ids = array($diff_id);
|
|
||||||
}
|
|
||||||
if ($diff_ids || $revision_ids) {
|
|
||||||
$diff = id(new DifferentialDiffQuery())
|
$diff = id(new DifferentialDiffQuery())
|
||||||
->setViewer($request->getUser())
|
->setViewer($request->getUser())
|
||||||
->withIDs($diff_ids)
|
->withIDs(array($diff_id))
|
||||||
->withRevisionIDs($revision_ids)
|
|
||||||
->needChangesets(true)
|
->needChangesets(true)
|
||||||
->needArcanistProjects(true)
|
->needArcanistProjects(true)
|
||||||
->executeOne();
|
->executeOne();
|
||||||
|
|
|
@ -13,7 +13,7 @@ final class ConduitAPI_differential_querydiffs_Method
|
||||||
public function defineParamTypes() {
|
public function defineParamTypes() {
|
||||||
return array(
|
return array(
|
||||||
'ids' => 'optional list<uint>',
|
'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) {
|
protected function execute(ConduitAPIRequest $request) {
|
||||||
$ids = $request->getValue('ids', array());
|
$ids = $request->getValue('ids', array());
|
||||||
$revision_ids = $request->getValue('revision_ids', array());
|
$revision_ids = $request->getValue('revisionIDs', array());
|
||||||
$diffs = array();
|
$diffs = array();
|
||||||
$diff_dicts = array();
|
$diff_dicts = array();
|
||||||
if ($ids || $revision_ids) {
|
if ($ids || $revision_ids) {
|
||||||
|
|
Loading…
Reference in a new issue