1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 14:51:06 +01:00

Always provide a viewer when executing DifferentialRevisionQuery

Summary: Ref T603. This query isn't policy-aware yet, but prepare for it to be one day.

Test Plan: Looked at: home page; differential home; differential detail; diffusion browse. Made differential.query conduit call.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D6337
This commit is contained in:
epriestley 2013-07-01 12:38:27 -07:00
parent ab2ed06c38
commit 328aa383e4
10 changed files with 25 additions and 18 deletions

View file

@ -81,6 +81,7 @@ final class PhabricatorApplicationDifferential extends PhabricatorApplication {
public function loadStatus(PhabricatorUser $user) { public function loadStatus(PhabricatorUser $user) {
$revisions = id(new DifferentialRevisionQuery()) $revisions = id(new DifferentialRevisionQuery())
->setViewer($user)
->withResponsibleUsers(array($user->getPHID())) ->withResponsibleUsers(array($user->getPHID()))
->withStatus(DifferentialRevisionQuery::STATUS_OPEN) ->withStatus(DifferentialRevisionQuery::STATUS_OPEN)
->needRelationships(true) ->needRelationships(true)

View file

@ -75,7 +75,9 @@ final class ConduitAPI_differential_query_Method
$branches = $request->getValue('branches'); $branches = $request->getValue('branches');
$arc_projects = $request->getValue('arcanistProjects'); $arc_projects = $request->getValue('arcanistProjects');
$query = new DifferentialRevisionQuery(); $query = id(new DifferentialRevisionQuery())
->setViewer($request->getUser());
if ($authors) { if ($authors) {
$query->withAuthors($authors); $query->withAuthors($authors);
} }

View file

@ -237,9 +237,9 @@ final class DifferentialRevisionListController extends DifferentialController {
private function buildQuery($filter, array $params) { private function buildQuery($filter, array $params) {
$user_phids = $params['view_users']; $user_phids = $params['view_users'];
$query = new DifferentialRevisionQuery(); $query = id(new DifferentialRevisionQuery())
->setViewer($this->getRequest()->getUser())
$query->needRelationships(true); ->needRelationships(true);
switch ($filter) { switch ($filter) {
case 'active': case 'active':

View file

@ -803,6 +803,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
} }
$query = id(new DifferentialRevisionQuery()) $query = id(new DifferentialRevisionQuery())
->setViewer($this->getRequest()->getUser())
->withStatus(DifferentialRevisionQuery::STATUS_OPEN) ->withStatus(DifferentialRevisionQuery::STATUS_OPEN)
->setOrder(DifferentialRevisionQuery::ORDER_PATH_MODIFIED) ->setOrder(DifferentialRevisionQuery::ORDER_PATH_MODIFIED)
->setLimit(10) ->setLimit(10)

View file

@ -61,6 +61,7 @@ final class DifferentialRevisionListView extends AphrontView {
->execute(); ->execute();
$this->drafts = id(new DifferentialRevisionQuery()) $this->drafts = id(new DifferentialRevisionQuery())
->setViewer($user)
->withIDs(mpull($this->revisions, 'getID')) ->withIDs(mpull($this->revisions, 'getID'))
->withDraftRepliesByAuthors(array($user->getPHID())) ->withDraftRepliesByAuthors(array($user->getPHID()))
->execute(); ->execute();

View file

@ -111,6 +111,7 @@ abstract class DiffusionController extends PhabricatorController {
} }
$revisions = id(new DifferentialRevisionQuery()) $revisions = id(new DifferentialRevisionQuery())
->setViewer($user)
->withPath($repository->getID(), $path_id) ->withPath($repository->getID(), $path_id)
->withStatus(DifferentialRevisionQuery::STATUS_OPEN) ->withStatus(DifferentialRevisionQuery::STATUS_OPEN)
->setOrder(DifferentialRevisionQuery::ORDER_PATH_MODIFIED) ->setOrder(DifferentialRevisionQuery::ORDER_PATH_MODIFIED)
@ -125,7 +126,7 @@ abstract class DiffusionController extends PhabricatorController {
$view = id(new DifferentialRevisionListView()) $view = id(new DifferentialRevisionListView())
->setRevisions($revisions) ->setRevisions($revisions)
->setFields(DifferentialRevisionListView::getDefaultFields($user)) ->setFields(DifferentialRevisionListView::getDefaultFields($user))
->setUser($this->getRequest()->getUser()) ->setUser($user)
->loadAssets(); ->loadAssets();
$phids = $view->getRequiredHandlePHIDs(); $phids = $view->getRequiredHandlePHIDs();

View file

@ -183,10 +183,11 @@ final class PhabricatorDirectoryMainController
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$user_phid = $user->getPHID(); $user_phid = $user->getPHID();
$revision_query = new DifferentialRevisionQuery(); $revision_query = id(new DifferentialRevisionQuery())
$revision_query->withStatus(DifferentialRevisionQuery::STATUS_OPEN); ->setViewer($user)
$revision_query->withResponsibleUsers(array($user_phid)); ->withStatus(DifferentialRevisionQuery::STATUS_OPEN)
$revision_query->needRelationships(true); ->withResponsibleUsers(array($user_phid))
->needRelationships(true);
// NOTE: We need to unlimit this query to hit the responsible user // NOTE: We need to unlimit this query to hit the responsible user
// fast-path. // fast-path.

View file

@ -108,11 +108,10 @@ final class PhabricatorObjectHandleData {
return mpull($lists, null, 'getPHID'); return mpull($lists, null, 'getPHID');
case PhabricatorPHIDConstants::PHID_TYPE_DREV: case PhabricatorPHIDConstants::PHID_TYPE_DREV:
// TODO: Update this to DifferentialRevisionQuery $revisions = id(new DifferentialRevisionQuery())
$revision_dao = new DifferentialRevision(); ->setViewer($this->viewer)
$revisions = $revision_dao->loadAllWhere( ->withPHIDs($phids)
'phid IN (%Ls)', ->execute();
$phids);
return mpull($revisions, null, 'getPHID'); return mpull($revisions, null, 'getPHID');
case PhabricatorPHIDConstants::PHID_TYPE_WIKI: case PhabricatorPHIDConstants::PHID_TYPE_WIKI:

View file

@ -20,6 +20,7 @@ final class ReleephDiffChurnFieldSpecification
$diff_rev = $this->getReleephRequest()->loadDifferentialRevision(); $diff_rev = $this->getReleephRequest()->loadDifferentialRevision();
$comments = id(new DifferentialRevisionQuery()) $comments = id(new DifferentialRevisionQuery())
->setViewer($this->getUser())
->withRevisionIDs(array($diff_rev->getID())) ->withRevisionIDs(array($diff_rev->getID()))
->excute(); ->excute();

View file

@ -100,10 +100,10 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
$this->repository, $this->repository,
$this->commit); $this->commit);
if ($hashes) { if ($hashes) {
$revisions = id(new DifferentialRevisionQuery())
$query = new DifferentialRevisionQuery(); ->setViewer(PhabricatorUser::getOmnipotentUser())
$query->withCommitHashes($hashes); ->withCommitHashes($hashes)
$revisions = $query->execute(); ->execute();
if (!empty($revisions)) { if (!empty($revisions)) {
$revision = $this->identifyBestRevision($revisions); $revision = $this->identifyBestRevision($revisions);