1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 18:22:41 +01:00

Lightly modernize NamedQueryQuery

Summary: Ref T12956. No real behavioral changes here, just slightly more modern code.

Test Plan: Reviewed named queries in Maniphest and "Edit Queries...".

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12956

Differential Revision: https://secure.phabricator.com/D18420
This commit is contained in:
epriestley 2017-08-14 08:58:32 -07:00
parent 48a74de0b6
commit 8c3243ef68

View file

@ -28,55 +28,46 @@ final class PhabricatorNamedQueryQuery
return $this; return $this;
} }
protected function loadPage() { public function newResultObject() {
$table = new PhabricatorNamedQuery(); return new PhabricatorNamedQuery();
$conn_r = $table->establishConnection('r');
$data = queryfx_all(
$conn_r,
'SELECT * FROM %T %Q %Q %Q',
$table->getTableName(),
$this->buildWhereClause($conn_r),
$this->buildOrderClause($conn_r),
$this->buildLimitClause($conn_r));
return $table->loadAllFromArray($data);
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function loadPage() {
$where = array(); return $this->loadStandardPage($this->newResultObject());
}
if ($this->ids) { protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->engineClassNames) { if ($this->engineClassNames !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'engineClassName IN (%Ls)', 'engineClassName IN (%Ls)',
$this->engineClassNames); $this->engineClassNames);
} }
if ($this->userPHIDs) { if ($this->userPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'userPHID IN (%Ls)', 'userPHID IN (%Ls)',
$this->userPHIDs); $this->userPHIDs);
} }
if ($this->queryKeys) { if ($this->queryKeys !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'queryKey IN (%Ls)', 'queryKey IN (%Ls)',
$this->queryKeys); $this->queryKeys);
} }
$where[] = $this->buildPagingClause($conn_r); return $where;
return $this->formatWhereClause($where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {