From 5ecc704c4e8fbec8c2e9e058ec49633776c3fd8c Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 11 Jun 2013 10:22:50 +0100 Subject: [PATCH] Issue #1993100 by damiankloip: Change hook_queue_info() 'worker callback' to be a callable. --- core/includes/common.inc | 4 ++-- core/modules/system/system.api.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/includes/common.inc b/core/includes/common.inc index bee692e23a3..4be06e252e1 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -4325,11 +4325,11 @@ function drupal_cron_run() { foreach ($queues as $queue_name => $info) { if (isset($info['cron'])) { - $function = $info['worker callback']; + $callback = $info['worker callback']; $end = time() + (isset($info['cron']['time']) ? $info['cron']['time'] : 15); $queue = Drupal::queue($queue_name); while (time() < $end && ($item = $queue->claimItem())) { - $function($item->data); + call_user_func_array($callback, array($item->data)); $queue->deleteItem($item); } } diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 0be782188f2..aedc6b1d4b0 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -211,7 +211,7 @@ function hook_data_type_info_alter(&$data_types) { * @return * An associative array where the key is the queue name and the value is * again an associative array. Possible keys are: - * - 'worker callback': The name of the function to call. It will be called + * - 'worker callback': A PHP callable to call. It will be called * with one argument, the item created via * Drupal\Core\Queue\QueueInterface::createItem() in hook_cron(). * - 'cron': (optional) An associative array containing the optional key: @@ -226,7 +226,7 @@ function hook_data_type_info_alter(&$data_types) { function hook_queue_info() { $queues['aggregator_feeds'] = array( 'title' => t('Aggregator refresh'), - 'worker callback' => 'aggregator_refresh', + 'worker callback' => array('Drupal\my_module\MyClass', 'aggregatorRefresh'), // Only needed if this queue should be processed by cron. 'cron' => array( 'time' => 60,