diff --git a/src/applications/differential/query/DifferentialRevisionQuery.php b/src/applications/differential/query/DifferentialRevisionQuery.php index 69e9477e0d..30731b6fed 100644 --- a/src/applications/differential/query/DifferentialRevisionQuery.php +++ b/src/applications/differential/query/DifferentialRevisionQuery.php @@ -771,19 +771,23 @@ 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. + switch ($this->status) { case self::STATUS_ANY: break; case self::STATUS_OPEN: $where[] = qsprintf( $conn_r, - 'r.status IN (%Ld)', + 'r.status IN (%Ls)', DifferentialRevisionStatus::getOpenStatuses()); break; case self::STATUS_NEEDS_REVIEW: $where[] = qsprintf( $conn_r, - 'r.status IN (%Ld)', + 'r.status IN (%Ls)', array( ArcanistDifferentialRevisionStatus::NEEDS_REVIEW, )); @@ -791,7 +795,7 @@ final class DifferentialRevisionQuery case self::STATUS_NEEDS_REVISION: $where[] = qsprintf( $conn_r, - 'r.status IN (%Ld)', + 'r.status IN (%Ls)', array( ArcanistDifferentialRevisionStatus::NEEDS_REVISION, )); @@ -799,7 +803,7 @@ final class DifferentialRevisionQuery case self::STATUS_ACCEPTED: $where[] = qsprintf( $conn_r, - 'r.status IN (%Ld)', + 'r.status IN (%Ls)', array( ArcanistDifferentialRevisionStatus::ACCEPTED, )); @@ -807,13 +811,13 @@ final class DifferentialRevisionQuery case self::STATUS_CLOSED: $where[] = qsprintf( $conn_r, - 'r.status IN (%Ld)', + 'r.status IN (%Ls)', DifferentialRevisionStatus::getClosedStatuses()); break; case self::STATUS_ABANDONED: $where[] = qsprintf( $conn_r, - 'r.status IN (%Ld)', + 'r.status IN (%Ls)', array( ArcanistDifferentialRevisionStatus::ABANDONED, )); diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php index 5f2131475b..affa0c4d9a 100644 --- a/src/applications/differential/storage/DifferentialRevision.php +++ b/src/applications/differential/storage/DifferentialRevision.php @@ -102,6 +102,14 @@ final class DifferentialRevision extends DifferentialDAO 'repositoryPHID' => array( 'columns' => array('repositoryPHID'), ), + // If you (or a project you are a member of) is reviewing a significant + // fraction of the revisions on an install, the result set of open + // revisions may be smaller than the result set of revisions where you + // are a reviewer. In these cases, this key is better than keys on the + // edge table. + 'key_status' => array( + 'columns' => array('status', 'phid'), + ), ), ) + parent::getConfiguration(); }