mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
DiffusionCommitQuery - move phid to id mapping
Summary: Ref T5862. makes the exception work better Test Plan: issued some queries from audit ui with and without repos - they worked Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T5862 Differential Revision: https://secure.phabricator.com/D10268
This commit is contained in:
parent
644e950ea3
commit
f8af89a99e
2 changed files with 18 additions and 14 deletions
|
@ -61,9 +61,6 @@ final class PhabricatorCommitSearchEngine
|
|||
|
||||
$repository_phids = $saved->getParameter('repositoryPHIDs', array());
|
||||
if ($repository_phids) {
|
||||
// $repository_phids need to be mapped to $repository_ids via a subquery
|
||||
// so make sure $viewer is set...!
|
||||
$query->setViewer($this->requireViewer());
|
||||
$query->withRepositoryPHIDs($repository_phids);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ final class DiffusionCommitQuery
|
|||
private $defaultRepository;
|
||||
private $identifiers;
|
||||
private $repositoryIDs;
|
||||
private $repositoryPHIDs;
|
||||
private $identifierMap;
|
||||
|
||||
private $needAuditRequests;
|
||||
|
@ -63,19 +64,9 @@ final class DiffusionCommitQuery
|
|||
* Look up commits in a specific repository. Prefer
|
||||
* @{method:withRepositoryIDs}; the underyling table is keyed by ID such
|
||||
* that this method requires a separate initial query to map PHID to ID.
|
||||
* Furthermore, this method requires calling @{method:setViewer} in
|
||||
* advance due to the separate query.
|
||||
*/
|
||||
public function withRepositoryPHIDs(array $phids) {
|
||||
$repositories = id (new PhabricatorRepositoryQuery())
|
||||
->setViewer($this->getViewer())
|
||||
->withPHIDs($phids)
|
||||
->execute();
|
||||
|
||||
if (!$repositories) {
|
||||
throw new PhabricatorEmptyQueryException();
|
||||
}
|
||||
$this->withRepositoryIDs(mpull($repositories, 'getID'));
|
||||
$this->repositoryPHIDs = $phids;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -282,6 +273,22 @@ final class DiffusionCommitQuery
|
|||
private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
|
||||
$where = array();
|
||||
|
||||
if ($this->repositoryPHIDs !== null) {
|
||||
$map_repositories = id (new PhabricatorRepositoryQuery())
|
||||
->setViewer($this->getViewer())
|
||||
->withPHIDs($this->repositoryPHIDs)
|
||||
->execute();
|
||||
|
||||
if (!$map_repositories) {
|
||||
throw new PhabricatorEmptyQueryException();
|
||||
}
|
||||
$repository_ids = mpull($map_repositories, 'getID');
|
||||
if ($this->repositoryIDs !== null) {
|
||||
$repository_ids = array_merge($repository_ids, $this->repositoryIDs);
|
||||
}
|
||||
$this->withRepositoryIDs($repository_ids);
|
||||
}
|
||||
|
||||
if ($this->ids !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
|
|
Loading…
Reference in a new issue