@@ -606,8 +606,8 @@ function hook_cron() {
606
606
* @return
607
607
* An associative array where the key is the queue name and the value is
608
608
* 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 ().
611
611
* - 'time': (optional) How much time Drupal should spend on calling this
612
612
* worker in seconds. Defaults to 15.
613
613
* - 'skip on cron': (optional) Set to TRUE to avoid being processed during
@@ -643,6 +643,28 @@ function hook_cron_queue_info_alter(&$queues) {
643
643
$ queues ['aggregator_feeds ' ]['time ' ] = 90 ;
644
644
}
645
645
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
+
646
668
/**
647
669
* Allows modules to declare their own Form API element types and specify their
648
670
* default values.
0 commit comments