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

Use DifferentialRevisionQuery in differential controllers

Summary:
Change all instances of `id(new DifferentialRevision())->load($id)` for `DifferentialRevisionQuery` where reviewers are loaded.
Also make sure that the new reviewer status is being loaded so that all calls to `getReviewers` can be removed in the near future.

Test Plan: Use all three controllers with several revisions and check they still work in sane way

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1279

Differential Revision: https://secure.phabricator.com/D6466
This commit is contained in:
Juan Pablo Civile 2013-07-15 16:01:31 -07:00 committed by epriestley
parent 10c9e38706
commit ee9fac5c8f
3 changed files with 16 additions and 6 deletions

View file

@ -20,15 +20,17 @@ final class DifferentialRevisionEditController extends DifferentialController {
$revision = id(new DifferentialRevisionQuery()) $revision = id(new DifferentialRevisionQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($this->id))
->needRelationships(true)
->needReviewerStatus(true)
->executeOne(); ->executeOne();
if (!$revision) { if (!$revision) {
return new Aphront404Response(); return new Aphront404Response();
} }
} else { } else {
$revision = new DifferentialRevision(); $revision = new DifferentialRevision();
$revision->attachRelationships(array());
} }
$revision->loadRelationships();
$aux_fields = $this->loadAuxiliaryFields($revision); $aux_fields = $this->loadAuxiliaryFields($revision);
$diff_id = $request->getInt('diffID'); $diff_id = $request->getInt('diffID');

View file

@ -18,13 +18,17 @@ final class DifferentialRevisionViewController extends DifferentialController {
$user = $request->getUser(); $user = $request->getUser();
$viewer_is_anonymous = !$user->isLoggedIn(); $viewer_is_anonymous = !$user->isLoggedIn();
$revision = id(new DifferentialRevision())->load($this->revisionID); $revision = id(new DifferentialRevisionQuery())
->withIDs(array($this->revisionID))
->setViewer($request->getUser())
->needRelationships(true)
->needReviewerStatus(true)
->executeOne();
if (!$revision) { if (!$revision) {
return new Aphront404Response(); return new Aphront404Response();
} }
$revision->loadRelationships();
$diffs = $revision->loadDiffs(); $diffs = $revision->loadDiffs();
if (!$diffs) { if (!$diffs) {

View file

@ -15,7 +15,12 @@ final class DifferentialSubscribeController extends DifferentialController {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$revision = id(new DifferentialRevision())->load($this->id); $revision = id(new DifferentialRevisionQuery())
->withIDs(array($this->id))
->setViewer($request->getUser())
->needRelationships(true)
->needReviewerStatus(true)
->executeOne();
if (!$revision) { if (!$revision) {
return new Aphront404Response(); return new Aphront404Response();
} }
@ -51,7 +56,6 @@ final class DifferentialSubscribeController extends DifferentialController {
return id(new AphrontDialogResponse())->setDialog($dialog); return id(new AphrontDialogResponse())->setDialog($dialog);
} }
$revision->loadRelationships();
$phid = $user->getPHID(); $phid = $user->getPHID();
switch ($this->action) { switch ($this->action) {