1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-05 12:21:02 +01:00

Use DifferentialRevisionQuery in conduit when reviewers are needed

Summary:
Ref T1279.

Switched all differential conduit methods to use `DifferentialRevisionQuery` where `loadRelations` was being used.

Test Plan: Called all the methods changed and verified they still worked as advertised.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T603, T1279

Differential Revision: https://secure.phabricator.com/D6452
This commit is contained in:
Juan Pablo Civile 2013-07-15 03:29:12 -07:00 committed by epriestley
parent d4c28dcbc2
commit d6ce5a31e3
4 changed files with 27 additions and 10 deletions

View file

@ -29,7 +29,12 @@ final class ConduitAPI_differential_close_Method
protected function execute(ConduitAPIRequest $request) { protected function execute(ConduitAPIRequest $request) {
$id = $request->getValue('revisionID'); $id = $request->getValue('revisionID');
$revision = id(new DifferentialRevision())->load($id); $revision = id(new DifferentialRevisionQuery())
->withIDs(array($id))
->setViewer($request->getUser())
->needRelationships(true)
->needReviewerStatus(true)
->executeOne();
if (!$revision) { if (!$revision) {
throw new ConduitException('ERR_NOT_FOUND'); throw new ConduitException('ERR_NOT_FOUND');
} }
@ -43,8 +48,6 @@ final class ConduitAPI_differential_close_Method
return; return;
} }
$revision->loadRelationships();
$content_source = PhabricatorContentSource::newForSource( $content_source = PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_CONDUIT, PhabricatorContentSource::SOURCE_CONDUIT,
array()); array());

View file

@ -32,15 +32,21 @@ final class ConduitAPI_differential_getcommitmessage_Method
$id = $request->getValue('revision_id'); $id = $request->getValue('revision_id');
if ($id) { if ($id) {
$revision = id(new DifferentialRevision())->load($id); $revision = id(new DifferentialRevisionQuery())
->withIDs(array($id))
->setViewer($request->getUser())
->needRelationships(true)
->needReviewerStatus(true)
->executeOne();
if (!$revision) { if (!$revision) {
throw new ConduitException('ERR_NOT_FOUND'); throw new ConduitException('ERR_NOT_FOUND');
} }
} else { } else {
$revision = new DifferentialRevision(); $revision = new DifferentialRevision();
$revision->attachRelationships(array());
} }
$revision->loadRelationships();
$is_edit = $request->getValue('edit'); $is_edit = $request->getValue('edit');
$is_create = ($is_edit == 'create'); $is_create = ($is_edit == 'create');

View file

@ -38,12 +38,17 @@ final class ConduitAPI_differential_getrevision_Method
$diff = null; $diff = null;
$revision_id = $request->getValue('revision_id'); $revision_id = $request->getValue('revision_id');
$revision = id(new DifferentialRevision())->load($revision_id); $revision = id(new DifferentialRevisionQuery())
->withIDs(array($revision_id))
->setViewer($request->getUser())
->needRelationships(true)
->needReviewerStatus(true)
->executeOne();
if (!$revision) { if (!$revision) {
throw new ConduitException('ERR_BAD_REVISION'); throw new ConduitException('ERR_BAD_REVISION');
} }
$revision->loadRelationships();
$reviewer_phids = array_values($revision->getReviewers()); $reviewer_phids = array_values($revision->getReviewers());
$diffs = $revision->loadDiffs(); $diffs = $revision->loadDiffs();

View file

@ -38,7 +38,12 @@ final class ConduitAPI_differential_markcommitted_Method
protected function execute(ConduitAPIRequest $request) { protected function execute(ConduitAPIRequest $request) {
$id = $request->getValue('revision_id'); $id = $request->getValue('revision_id');
$revision = id(new DifferentialRevision())->load($id); $revision = id(new DifferentialRevisionQuery())
->withIDs(array($id))
->setViewer($request->getUser())
->needRelationships(true)
->needReviewerStatus(true)
->executeOne();
if (!$revision) { if (!$revision) {
throw new ConduitException('ERR_NOT_FOUND'); throw new ConduitException('ERR_NOT_FOUND');
} }
@ -47,8 +52,6 @@ final class ConduitAPI_differential_markcommitted_Method
return; return;
} }
$revision->loadRelationships();
$editor = new DifferentialCommentEditor( $editor = new DifferentialCommentEditor(
$revision, $revision,
DifferentialAction::ACTION_CLOSE); DifferentialAction::ACTION_CLOSE);