From 13ddb15bbcfb107580cdfdb6fa1677479d5640c9 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 11 Aug 2017 09:28:05 -0700 Subject: [PATCH] Remove legacy `withStatus()` method from RevisionQuery Summary: Ref T2543. All callsites are now in terms of `withStatuses()`. Test Plan: - Called `differential.query` and `differential.find` from Conduit API. - Grepped through all `withStatus()` callsites. Reviewers: chad Reviewed By: chad Maniphest Tasks: T2543 Differential Revision: https://secure.phabricator.com/D18396 --- .../DifferentialFindConduitAPIMethod.php | 4 +-- .../DifferentialQueryConduitAPIMethod.php | 5 ++- .../constants/DifferentialLegacyQuery.php | 4 +-- .../query/DifferentialRevisionQuery.php | 32 ++----------------- 4 files changed, 11 insertions(+), 34 deletions(-) diff --git a/src/applications/differential/conduit/DifferentialFindConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialFindConduitAPIMethod.php index a199f599e8..8a8b8c8198 100644 --- a/src/applications/differential/conduit/DifferentialFindConduitAPIMethod.php +++ b/src/applications/differential/conduit/DifferentialFindConduitAPIMethod.php @@ -52,12 +52,12 @@ final class DifferentialFindConduitAPIMethod switch ($type) { case 'open': $query - ->withStatus(DifferentialLegacyQuery::STATUS_OPEN) + ->withIsOpen(true) ->withAuthors($guids); break; case 'committable': $query - ->withStatus(DifferentialLegacyQuery::STATUS_ACCEPTED) + ->withStatuses(DifferentialRevisionStatus::ACCEPTED) ->withAuthors($guids); break; case 'revision-ids': diff --git a/src/applications/differential/conduit/DifferentialQueryConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialQueryConduitAPIMethod.php index 329a44c857..0064e70665 100644 --- a/src/applications/differential/conduit/DifferentialQueryConduitAPIMethod.php +++ b/src/applications/differential/conduit/DifferentialQueryConduitAPIMethod.php @@ -150,7 +150,10 @@ final class DifferentialQueryConduitAPIMethod } if ($status) { - $query->withStatus($status); + $statuses = DifferentialLegacyQuery::getModernValues($status); + if ($statuses) { + $query->withStatuses($statuses); + } } if ($order) { $query->setOrder($order); diff --git a/src/applications/differential/constants/DifferentialLegacyQuery.php b/src/applications/differential/constants/DifferentialLegacyQuery.php index 6a87688e99..ca254918e0 100644 --- a/src/applications/differential/constants/DifferentialLegacyQuery.php +++ b/src/applications/differential/constants/DifferentialLegacyQuery.php @@ -15,7 +15,7 @@ final class DifferentialLegacyQuery return array_keys(self::getMap()); } - public static function getQueryValues($status) { + public static function getModernValues($status) { if ($status === self::STATUS_ANY) { return null; } @@ -28,7 +28,7 @@ final class DifferentialLegacyQuery $status)); } - return self::getLegacyValues($map[$status]); + return $map[$status]; } public static function getLegacyValues(array $modern_values) { diff --git a/src/applications/differential/query/DifferentialRevisionQuery.php b/src/applications/differential/query/DifferentialRevisionQuery.php index 8d8169a66e..39bba8112d 100644 --- a/src/applications/differential/query/DifferentialRevisionQuery.php +++ b/src/applications/differential/query/DifferentialRevisionQuery.php @@ -10,8 +10,6 @@ final class DifferentialRevisionQuery private $pathIDs = array(); - private $status = 'status-any'; - private $authors = array(); private $draftAuthors = array(); private $ccs = array(); @@ -135,19 +133,6 @@ final class DifferentialRevisionQuery return $this; } - /** - * Filter results to revisions with a given status. Provide a class constant, - * such as `DifferentialLegacyQuery::STATUS_OPEN`. - * - * @param const Class STATUS constant, like STATUS_OPEN. - * @return this - * @task config - */ - public function withStatus($status_constant) { - $this->status = $status_constant; - return $this; - } - public function withStatuses(array $statuses) { $this->statuses = $statuses; return $this; @@ -706,17 +691,6 @@ final class DifferentialRevisionQuery $this->updatedEpochMax); } - // NOTE: Although the status constants are integers in PHP, the column is a - // string column in MySQL, and MySQL won't use keys on string columns if - // you put integers in the query. - $statuses = DifferentialLegacyQuery::getQueryValues($this->status); - if ($statuses !== null) { - $where[] = qsprintf( - $conn_r, - 'r.status IN (%Ls)', - $statuses); - } - if ($this->statuses !== null) { $where[] = qsprintf( $conn_r, @@ -726,16 +700,16 @@ final class DifferentialRevisionQuery if ($this->isOpen !== null) { if ($this->isOpen) { - $statuses = DifferentialLegacyQuery::getQueryValues( + $statuses = DifferentialLegacyQuery::getModernValues( DifferentialLegacyQuery::STATUS_OPEN); } else { - $statuses = DifferentialLegacyQuery::getQueryValues( + $statuses = DifferentialLegacyQuery::getModernValues( DifferentialLegacyQuery::STATUS_CLOSED); } $where[] = qsprintf( $conn_r, 'r.status in (%Ls)', - $statuses); + DifferentialLegacyQuery::getLegacyValues($statuses)); } $where[] = $this->buildWhereClauseParts($conn_r);