Skip to content
Snippets Groups Projects
Commit 3c6f01be authored by Florian Loretan's avatar Florian Loretan
Browse files

Issue #2594549: Update cron integration to match current API

parent 8999a221
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment