diff --git a/src/applications/differential/constants/DifferentialLegacyQuery.php b/src/applications/differential/constants/DifferentialLegacyQuery.php index 4a20267f10..6a87688e99 100644 --- a/src/applications/differential/constants/DifferentialLegacyQuery.php +++ b/src/applications/differential/constants/DifferentialLegacyQuery.php @@ -28,8 +28,12 @@ final class DifferentialLegacyQuery $status)); } + return self::getLegacyValues($map[$status]); + } + + public static function getLegacyValues(array $modern_values) { $values = array(); - foreach ($map[$status] as $status_constant) { + foreach ($modern_values as $status_constant) { $status_object = DifferentialRevisionStatus::newForStatus( $status_constant); diff --git a/src/applications/differential/query/DifferentialRevisionQuery.php b/src/applications/differential/query/DifferentialRevisionQuery.php index f53ec46a9f..79227df8ac 100644 --- a/src/applications/differential/query/DifferentialRevisionQuery.php +++ b/src/applications/differential/query/DifferentialRevisionQuery.php @@ -25,6 +25,7 @@ final class DifferentialRevisionQuery private $repositoryPHIDs; private $updatedEpochMin; private $updatedEpochMax; + private $statuses; const ORDER_MODIFIED = 'order-modified'; const ORDER_CREATED = 'order-created'; @@ -146,6 +147,11 @@ final class DifferentialRevisionQuery return $this; } + public function withStatuses(array $statuses) { + $this->statuses = $statuses; + return $this; + } + /** * Filter results to revisions on given branches. @@ -705,6 +711,13 @@ final class DifferentialRevisionQuery $statuses); } + if ($this->statuses !== null) { + $where[] = qsprintf( + $conn_r, + 'r.status in (%Ls)', + DifferentialLegacyQuery::getLegacyValues($this->statuses)); + } + $where[] = $this->buildWhereClauseParts($conn_r); return $this->formatWhereClause($where); } diff --git a/src/applications/differential/query/DifferentialRevisionSearchEngine.php b/src/applications/differential/query/DifferentialRevisionSearchEngine.php index 8cb8ffd2fb..dcbbaeedee 100644 --- a/src/applications/differential/query/DifferentialRevisionSearchEngine.php +++ b/src/applications/differential/query/DifferentialRevisionSearchEngine.php @@ -41,8 +41,8 @@ final class DifferentialRevisionSearchEngine $query->withRepositoryPHIDs($map['repositoryPHIDs']); } - if ($map['status']) { - $query->withStatus($map['status']); + if ($map['statuses']) { + $query->withStatuses($map['statuses']); } return $query; @@ -77,10 +77,11 @@ final class DifferentialRevisionSearchEngine ->setDatasource(new DiffusionRepositoryFunctionDatasource()) ->setDescription( pht('Find revisions from specific repositories.')), - id(new PhabricatorSearchSelectField()) - ->setLabel(pht('Status')) - ->setKey('status') - ->setOptions($this->getStatusOptions()) + id(new PhabricatorSearchDatasourceField()) + ->setLabel(pht('Statuses')) + ->setKey('statuses') + ->setAliases(array('status')) + ->setDatasource(new DifferentialRevisionStatusFunctionDatasource()) ->setDescription( pht('Find revisions with particular statuses.')), ); @@ -115,7 +116,7 @@ final class DifferentialRevisionSearchEngine return $query ->setParameter('responsiblePHIDs', array($viewer->getPHID())) - ->setParameter('status', DifferentialLegacyQuery::STATUS_OPEN) + ->setParameter('statuses', array('open()')) ->setParameter('bucket', $bucket_key); case 'authored': return $query