From bfbf75a8720c0600fa240706f29b556be59a310f Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 6 Dec 2016 04:16:49 -0800 Subject: [PATCH] Slightly modernize ConduitTokenQuery Summary: Ref T11954. This old query class can use slightly more modern code. Test Plan: Ran Conduit methods, verified results are unchanged. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11954 Differential Revision: https://secure.phabricator.com/D16996 --- .../query/PhabricatorConduitTokenQuery.php | 39 +++++++------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/src/applications/conduit/query/PhabricatorConduitTokenQuery.php b/src/applications/conduit/query/PhabricatorConduitTokenQuery.php index 44586f1815..ef35b006a7 100644 --- a/src/applications/conduit/query/PhabricatorConduitTokenQuery.php +++ b/src/applications/conduit/query/PhabricatorConduitTokenQuery.php @@ -34,48 +34,41 @@ final class PhabricatorConduitTokenQuery return $this; } - protected function loadPage() { - $table = new PhabricatorConduitToken(); - $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); + public function newResultObject() { + return new PhabricatorConduitToken(); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { - $where = array(); + protected function loadPage() { + return $this->loadStandardPage($this->newResultObject()); + } + + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { + $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->objectPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'objectPHID IN (%Ls)', $this->objectPHIDs); } if ($this->tokens !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'token IN (%Ls)', $this->tokens); } if ($this->tokenTypes !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'tokenType IN (%Ls)', $this->tokenTypes); } @@ -83,20 +76,18 @@ final class PhabricatorConduitTokenQuery if ($this->expired !== null) { if ($this->expired) { $where[] = qsprintf( - $conn_r, + $conn, 'expires <= %d', PhabricatorTime::getNow()); } else { $where[] = qsprintf( - $conn_r, + $conn, 'expires IS NULL OR expires > %d', PhabricatorTime::getNow()); } } - $where[] = $this->buildPagingClause($conn_r); - - return $this->formatWhereClause($where); + return $where; } protected function willFilterPage(array $tokens) {