From 8ec1da43081479521806312699627c97a3b614fe Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sat, 25 Dec 2021 01:25:56 -0800 Subject: [PATCH] SqlParallel - Fix compatiblity with `release_time` The scenario `CRM_Queue_QueueTest::testTimeoutRelease()` ensures that queue-items can be released for re-try after some period of time. The test was not running with `SqlParallel` backend -- and once I tried enableing it, it failed. The patch enables testing for `SqlParallel` and gets it to pass. --- CRM/Queue/Queue/SqlParallel.php | 3 ++- tests/phpunit/CRM/Queue/QueueTest.php | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CRM/Queue/Queue/SqlParallel.php b/CRM/Queue/Queue/SqlParallel.php index 9eb12ac883..369e7d2cef 100644 --- a/CRM/Queue/Queue/SqlParallel.php +++ b/CRM/Queue/Queue/SqlParallel.php @@ -116,12 +116,13 @@ class CRM_Queue_Queue_SqlParallel extends CRM_Queue_Queue { $sql = "SELECT id, queue_name, submit_time, release_time, data FROM civicrm_queue_item WHERE queue_name = %1 - AND release_time IS NULL + AND (release_time IS NULL OR release_time < %2) ORDER BY weight ASC, id ASC LIMIT 1 "; $params = [ 1 => [$this->getName(), 'String'], + 2 => [CRM_Utils_Time::getTime(), 'Timestamp'], ]; $dao = CRM_Core_DAO::executeQuery($sql, $params, TRUE, 'CRM_Queue_DAO_QueueItem'); if (is_a($dao, 'DB_Error')) { diff --git a/tests/phpunit/CRM/Queue/QueueTest.php b/tests/phpunit/CRM/Queue/QueueTest.php index 90ae12131b..b89319e7b1 100644 --- a/tests/phpunit/CRM/Queue/QueueTest.php +++ b/tests/phpunit/CRM/Queue/QueueTest.php @@ -36,6 +36,12 @@ class CRM_Queue_QueueTest extends CiviUnitTestCase { 'name' => 'test-queue', ], ]; + $queueSpecs[] = [ + [ + 'type' => 'SqlParallel', + 'name' => 'test-queue-sqlparallel', + ], + ]; return $queueSpecs; } -- 2.25.1