@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Skip Ferret fulltext columns in "ORDER BY" if there's no fulltext query

Summary:
Ref T13091. If you "Order By: Relevance" but don't actually specify a query, we currently raise a bare exception.

This operation is sort of silly/pointless, but it seems like it's probably best to just return the results for the other constraints in the fallback order (usually, by ID). Alternatively, we could raise a non-bare exception here ("You need to provide a fulltext query to order by relevance.")

Test Plan: Queried tasks by relevance with no actual query text.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13091

Differential Revision: https://secure.phabricator.com/D20296

+31 -2
+31 -2
src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
··· 538 538 */ 539 539 protected function buildPagingClause(AphrontDatabaseConnection $conn) { 540 540 $orderable = $this->getOrderableColumns(); 541 - $vector = $this->getOrderVector(); 541 + $vector = $this->getQueryableOrderVector(); 542 542 543 543 // If we don't have a cursor object yet, it means we're trying to load 544 544 // the first result page. We may need to build a cursor object from the ··· 1099 1099 'table' => null, 1100 1100 'column' => '_ft_rank', 1101 1101 'type' => 'int', 1102 + 'requires-ferret' => true, 1102 1103 ); 1103 1104 $columns['fulltext-created'] = array( 1104 1105 'table' => 'ft_doc', 1105 1106 'column' => 'epochCreated', 1106 1107 'type' => 'int', 1108 + 'requires-ferret' => true, 1107 1109 ); 1108 1110 $columns['fulltext-modified'] = array( 1109 1111 'table' => 'ft_doc', 1110 1112 'column' => 'epochModified', 1111 1113 'type' => 'int', 1114 + 'requires-ferret' => true, 1112 1115 ); 1113 1116 } 1114 1117 ··· 1126 1129 $for_union = false) { 1127 1130 1128 1131 $orderable = $this->getOrderableColumns(); 1129 - $vector = $this->getOrderVector(); 1132 + $vector = $this->getQueryableOrderVector(); 1130 1133 1131 1134 $parts = array(); 1132 1135 foreach ($vector as $order) { 1133 1136 $part = $orderable[$order->getOrderKey()]; 1137 + 1134 1138 if ($order->getIsReversed()) { 1135 1139 $part['reverse'] = !idx($part, 'reverse', false); 1136 1140 } ··· 1140 1144 return $this->formatOrderClause($conn, $parts, $for_union); 1141 1145 } 1142 1146 1147 + /** 1148 + * @task order 1149 + */ 1150 + private function getQueryableOrderVector() { 1151 + $vector = $this->getOrderVector(); 1152 + $orderable = $this->getOrderableColumns(); 1153 + 1154 + $keep = array(); 1155 + foreach ($vector as $order) { 1156 + $column = $orderable[$order->getOrderKey()]; 1157 + 1158 + // If this is a Ferret fulltext column but the query doesn't actually 1159 + // have a fulltext query, we'll skip most of the Ferret stuff and won't 1160 + // actually have the columns in the result set. Just skip them. 1161 + if (!empty($column['requires-ferret'])) { 1162 + if (!$this->getFerretTokens()) { 1163 + continue; 1164 + } 1165 + } 1166 + 1167 + $keep[] = $order->getAsScalar(); 1168 + } 1169 + 1170 + return PhabricatorQueryOrderVector::newFromVector($keep); 1171 + } 1143 1172 1144 1173 /** 1145 1174 * @task order