diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php --- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php +++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php @@ -212,7 +212,7 @@ } if ($this->supportsFerretEngine()) { - if ($this->getFerretTokens()) { + if ($this->hasFerretOrder()) { $map += array( 'rank' => $cursor->getRawRowProperty(self::FULLTEXT_RANK), @@ -1840,15 +1840,16 @@ return $select; } - $vector = $this->getOrderVector(); - if (!$vector->containsKey('rank')) { - // We only need to SELECT the virtual "_ft_rank" column if we're + if (!$this->hasFerretOrder()) { + // We only need to SELECT the virtual rank/relevance columns if we're // actually sorting the results by rank. return $select; } if (!$this->ferretEngine) { $select[] = qsprintf($conn, '0 AS %T', self::FULLTEXT_RANK); + $select[] = qsprintf($conn, '0 AS %T', self::FULLTEXT_CREATED); + $select[] = qsprintf($conn, '0 AS %T', self::FULLTEXT_MODIFIED); return $select; } @@ -3152,4 +3153,22 @@ } } + private function hasFerretOrder() { + $vector = $this->getOrderVector(); + + if ($vector->containsKey('rank')) { + return true; + } + + if ($vector->containsKey('fulltext-created')) { + return true; + } + + if ($vector->containsKey('fulltext-modified')) { + return true; + } + + return false; + } + }