1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +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) {
$revisions = id(new DifferentialRevisionQuery())
->setViewer($user)
->withResponsibleUsers(array($user->getPHID()))
->withStatus(DifferentialRevisionQuery::STATUS_OPEN)
->needRelationships(true)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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