diff --git a/src/applications/diffusion/conduit/DiffusionFindSymbolsConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionFindSymbolsConduitAPIMethod.php index f7dbb0de2a..34575ae99d 100644 --- a/src/applications/diffusion/conduit/DiffusionFindSymbolsConduitAPIMethod.php +++ b/src/applications/diffusion/conduit/DiffusionFindSymbolsConduitAPIMethod.php @@ -37,7 +37,8 @@ final class DiffusionFindSymbolsConduitAPIMethod $language = $request->getValue('language'); $type = $request->getValue('type'); - $query = new DiffusionSymbolQuery(); + $query = id(new DiffusionSymbolQuery()) + ->setViewer($request->getUser()); if ($name !== null) { $query->setName($name); } diff --git a/src/applications/diffusion/controller/DiffusionSymbolController.php b/src/applications/diffusion/controller/DiffusionSymbolController.php index 70ca8e1073..104b9fc515 100644 --- a/src/applications/diffusion/controller/DiffusionSymbolController.php +++ b/src/applications/diffusion/controller/DiffusionSymbolController.php @@ -8,8 +8,9 @@ final class DiffusionSymbolController extends DiffusionController { $user = $request->getUser(); $this->name = $request->getURIData('name'); - $query = new DiffusionSymbolQuery(); - $query->setName($this->name); + $query = id(new DiffusionSymbolQuery()) + ->setViewer($user) + ->setName($this->name); if ($request->getStr('context') !== null) { $query->setContext($request->getStr('context')); diff --git a/src/applications/diffusion/query/DiffusionSymbolQuery.php b/src/applications/diffusion/query/DiffusionSymbolQuery.php index 4aa987fe45..e5cb2b91c4 100644 --- a/src/applications/diffusion/query/DiffusionSymbolQuery.php +++ b/src/applications/diffusion/query/DiffusionSymbolQuery.php @@ -11,6 +11,7 @@ */ final class DiffusionSymbolQuery extends PhabricatorOffsetPagedQuery { + private $viewer; private $context; private $namePrefix; private $name; @@ -26,6 +27,20 @@ final class DiffusionSymbolQuery extends PhabricatorOffsetPagedQuery { /* -( Configuring the Query )---------------------------------------------- */ + /** + * @task config + */ + public function setViewer(PhabricatorUser $viewer) { + $this->viewer = $viewer; + return $this; + } + + /** + * @task config + */ + public function getViewer() { + return $this->viewer; + } /** * @task config @@ -263,10 +278,10 @@ final class DiffusionSymbolQuery extends PhabricatorOffsetPagedQuery { $repo_ids = array_filter($repo_ids); if ($repo_ids) { - // TODO: (T603) Provide a viewer here. - $repos = id(new PhabricatorRepository())->loadAllWhere( - 'id IN (%Ld)', - $repo_ids); + $repos = id(new PhabricatorRepositoryQuery()) + ->setViewer($this->getViewer()) + ->withIDs($repo_ids) + ->execute(); } else { $repos = array(); } diff --git a/src/applications/diffusion/typeahead/DiffusionSymbolDatasource.php b/src/applications/diffusion/typeahead/DiffusionSymbolDatasource.php index 25886ccf44..97ab83f44d 100644 --- a/src/applications/diffusion/typeahead/DiffusionSymbolDatasource.php +++ b/src/applications/diffusion/typeahead/DiffusionSymbolDatasource.php @@ -19,6 +19,7 @@ final class DiffusionSymbolDatasource if (strlen($raw_query)) { $symbols = id(new DiffusionSymbolQuery()) + ->setViewer($viewer) ->setNamePrefix($raw_query) ->setLimit(15) ->needArcanistProjects(true)