Skip to content

Commit 76e3d53

Browse files
committed
Issue #2208649 by joachim, er.pushpinderrana: document queue worker callback
1 parent 1e3e775 commit 76e3d53

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

modules/system/system.api.php

+24-2
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ function hook_cron() {
606606
* @return
607607
* An associative array where the key is the queue name and the value is
608608
* again an associative array. Possible keys are:
609-
* - 'worker callback': The name of the function to call. It will be called
610-
* with one argument, the item created via DrupalQueue::createItem().
609+
* - 'worker callback': A PHP callable to call that is an implementation of
610+
* callback_queue_worker().
611611
* - 'time': (optional) How much time Drupal should spend on calling this
612612
* worker in seconds. Defaults to 15.
613613
* - 'skip on cron': (optional) Set to TRUE to avoid being processed during
@@ -643,6 +643,28 @@ function hook_cron_queue_info_alter(&$queues) {
643643
$queues['aggregator_feeds']['time'] = 90;
644644
}
645645

646+
/**
647+
* Work on a single queue item.
648+
*
649+
* Callback for hook_queue_info().
650+
*
651+
* @param $queue_item_data
652+
* The data that was passed to DrupalQueue::createItem() when the item was
653+
* queued.
654+
*
655+
* @throws \Exception
656+
* The worker callback may throw an exception to indicate there was a problem.
657+
* The cron process will log the exception, and leave the item in the queue to
658+
* be processed again later.
659+
*
660+
* @see drupal_cron_run()
661+
*/
662+
function callback_queue_worker($queue_item_data) {
663+
$node = node_load($queue_item_data);
664+
$node->title = 'Updated title';
665+
$node->save();
666+
}
667+
646668
/**
647669
* Allows modules to declare their own Form API element types and specify their
648670
* default values.

0 commit comments

Comments
 (0)