diff --git a/queue_ui.module b/queue_ui.module index 5b8920135fd5231e32ffa1bbde36a56bad040671..3395a4975d6c92a4e68777e0925cfd8b18d7b26d 100644 --- a/queue_ui.module +++ b/queue_ui.module @@ -159,25 +159,16 @@ function queue_ui_defined_queues() { } /** - * Implements hook_cron(). + * hook_queue_info_alter() */ -function queue_ui_cron() { - // Retrieve queues set for cron processing. - $defs = queue_ui_defined_queues(); - if (!empty($defs)) { - foreach ($defs as $name => $definition) { - $queue = Drupal::queue($name); - // A cron callback must be defined and there must be items in the queue. - if (isset($definition['cron']) && is_object($queue) && $queue->numberOfItems()) { - $active = variable_get('queue_ui_cron_' . $name, FALSE); - if ($active) { - // Pass $queue to cron callback for processing. - $function = $definition['cron']['callback']; - // Definitions can define arguments. - $args = isset($definition['cron']['callback']) ? $definition['cron']['callback'] : NULL; - $function($queue, $args); - } - } +function queue_ui_queue_info_alter(&$queues) { + foreach ($queues as $queue_name => $definition) { + + // Check if a time limit override exists for this queue. + $time_limit = \Drupal::state()->get('queue_ui_cron_' . $queue_name); + if (!is_null($time_limit)) { + // Override the original definition. + $queues[$queue_name]['cron']['time'] = $time_limit; } } }