From 02f83619eaee116b9bca384374523aee70c75ae4 Mon Sep 17 00:00:00 2001 From: Oleh Vehera <44159-voleger@users.noreply.drupalcode.org> Date: Wed, 2 Oct 2024 15:46:26 +0000 Subject: [PATCH] Issue #3318513 by voleger, kevinn: Allow to disable queue execution by cron service --- queue_ui.module | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/queue_ui.module b/queue_ui.module index aa12ee8..149ae3f 100644 --- a/queue_ui.module +++ b/queue_ui.module @@ -9,11 +9,23 @@ * Hook_queue_info_alter() */ function queue_ui_queue_info_alter(&$queues) { + $state = \Drupal::state(); foreach ($queues as $queueName => $definition) { // Check if a time limit override exists for this queue. - if ($time_limit = \Drupal::state()->get('queue_ui_cron_' . $queueName)) { + $time_limit = $state->get('queue_ui_cron_' . $queueName); + if ($time_limit === NULL) { + // Queue UI didn't managed this queue yet. + continue; + } + $time_limit = (string) $state->get('queue_ui_cron_' . $queueName); + // Check for the value including 0. + if ($time_limit !== '') { // Override the original definition. - $queues[$queueName]['cron']['time'] = $time_limit; + $queues[$queueName]['cron']['time'] = (int) $time_limit; + } + else { + // Disable cron. + unset($queues[$queueName]['cron']); } } } -- GitLab