Issue #1993100 by damiankloip: Change hook_queue_info() 'worker callback' to be a callable.
parent
0ac024db37
commit
5ecc704c4e
|
@ -4325,11 +4325,11 @@ function drupal_cron_run() {
|
||||||
|
|
||||||
foreach ($queues as $queue_name => $info) {
|
foreach ($queues as $queue_name => $info) {
|
||||||
if (isset($info['cron'])) {
|
if (isset($info['cron'])) {
|
||||||
$function = $info['worker callback'];
|
$callback = $info['worker callback'];
|
||||||
$end = time() + (isset($info['cron']['time']) ? $info['cron']['time'] : 15);
|
$end = time() + (isset($info['cron']['time']) ? $info['cron']['time'] : 15);
|
||||||
$queue = Drupal::queue($queue_name);
|
$queue = Drupal::queue($queue_name);
|
||||||
while (time() < $end && ($item = $queue->claimItem())) {
|
while (time() < $end && ($item = $queue->claimItem())) {
|
||||||
$function($item->data);
|
call_user_func_array($callback, array($item->data));
|
||||||
$queue->deleteItem($item);
|
$queue->deleteItem($item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ function hook_data_type_info_alter(&$data_types) {
|
||||||
* @return
|
* @return
|
||||||
* An associative array where the key is the queue name and the value is
|
* An associative array where the key is the queue name and the value is
|
||||||
* again an associative array. Possible keys are:
|
* 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
|
* with one argument, the item created via
|
||||||
* Drupal\Core\Queue\QueueInterface::createItem() in hook_cron().
|
* Drupal\Core\Queue\QueueInterface::createItem() in hook_cron().
|
||||||
* - 'cron': (optional) An associative array containing the optional key:
|
* - '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() {
|
function hook_queue_info() {
|
||||||
$queues['aggregator_feeds'] = array(
|
$queues['aggregator_feeds'] = array(
|
||||||
'title' => t('Aggregator refresh'),
|
'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.
|
// Only needed if this queue should be processed by cron.
|
||||||
'cron' => array(
|
'cron' => array(
|
||||||
'time' => 60,
|
'time' => 60,
|
||||||
|
|
Loading…
Reference in New Issue