From a6fbde784c71f166e53ba586555d1a8306583dcc Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 23 Jan 2018 08:08:03 -0800 Subject: [PATCH] Modernize "PhabricatorRepositoryPushEventQuery" Summary: Depends on D18914. Updates this Query to use slightly more modern construction while I'm working in adjacent code. Test Plan: Viewed push logs in web UI. Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D18915 --- .../PhabricatorRepositoryPushEventQuery.php | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/src/applications/repository/query/PhabricatorRepositoryPushEventQuery.php b/src/applications/repository/query/PhabricatorRepositoryPushEventQuery.php index a3bed7abd3..f3e5fc62b4 100644 --- a/src/applications/repository/query/PhabricatorRepositoryPushEventQuery.php +++ b/src/applications/repository/query/PhabricatorRepositoryPushEventQuery.php @@ -34,19 +34,12 @@ final class PhabricatorRepositoryPushEventQuery return $this; } + public function newResultObject() { + return new PhabricatorRepositoryPushEvent(); + } + protected function loadPage() { - $table = new PhabricatorRepositoryPushEvent(); - $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); + return $this->loadStandardPage($this->newResultObject()); } protected function willFilterPage(array $events) { @@ -88,40 +81,38 @@ final class PhabricatorRepositoryPushEventQuery return $events; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { - $where = array(); + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { + $where = parent::buildWhereClauseParts($conn); - if ($this->ids) { + if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } - if ($this->phids) { + if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } - if ($this->repositoryPHIDs) { + if ($this->repositoryPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'repositoryPHID IN (%Ls)', $this->repositoryPHIDs); } - if ($this->pusherPHIDs) { + if ($this->pusherPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'pusherPHID in (%Ls)', $this->pusherPHIDs); } - $where[] = $this->buildPagingClause($conn_r); - - return $this->formatWhereClause($where); + return $where; } public function getQueryApplicationClass() {