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

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
This commit is contained in:
epriestley 2017-08-11 09:28:05 -07:00
parent f25acf2dee
commit 13ddb15bbc
4 changed files with 11 additions and 34 deletions

View file

@ -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':

View file

@ -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);

View file

@ -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) {

View file

@ -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);