mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
Add order-by-ID to PhabricatorWorkerTriggerQuery
Summary: Ref T6881. By design, the EXECUTION order only selects tasks which have been scheduled (since it performs a JOIN). This is inconsistent with other queries and problematic for withID/withPHID queries which may want to select an unscheduled task. Switch to standard ID ordering by default. Test Plan: - Instances console now finds unscheduled triggers. - Verified that all existing queries specify an explicit order. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T6881 Differential Revision: https://secure.phabricator.com/D11436
This commit is contained in:
parent
cccdc48883
commit
ef106d2979
1 changed files with 16 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
|||
final class PhabricatorWorkerTriggerQuery
|
||||
extends PhabricatorOffsetPagedQuery {
|
||||
|
||||
const ORDER_ID = 'id';
|
||||
const ORDER_EXECUTION = 'execution';
|
||||
const ORDER_VERSION = 'version';
|
||||
|
||||
|
@ -14,7 +15,7 @@ final class PhabricatorWorkerTriggerQuery
|
|||
private $nextEpochMax;
|
||||
|
||||
private $needEvents;
|
||||
private $order = self::ORDER_EXECUTION;
|
||||
private $order = self::ORDER_ID;
|
||||
|
||||
public function withIDs(array $ids) {
|
||||
$this->ids = $ids;
|
||||
|
@ -43,6 +44,16 @@ final class PhabricatorWorkerTriggerQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the result order.
|
||||
*
|
||||
* Note that using `ORDER_EXECUTION` will also filter results to include only
|
||||
* triggers which have been scheduled to execute. You should not use this
|
||||
* ordering when querying for specific triggers, e.g. by ID or PHID.
|
||||
*
|
||||
* @param const Result order.
|
||||
* @return this
|
||||
*/
|
||||
public function setOrder($order) {
|
||||
$this->order = $order;
|
||||
return $this;
|
||||
|
@ -185,6 +196,10 @@ final class PhabricatorWorkerTriggerQuery
|
|||
|
||||
private function buildOrderClause(AphrontDatabaseConnection $conn_r) {
|
||||
switch ($this->order) {
|
||||
case self::ORDER_ID:
|
||||
return qsprintf(
|
||||
$conn_r,
|
||||
'ORDER BY id DESC');
|
||||
case self::ORDER_EXECUTION:
|
||||
return qsprintf(
|
||||
$conn_r,
|
||||
|
|
Loading…
Reference in a new issue