incorrect docs for hook_cron_job_scheduler_info() 'queue name'

Created on 24 January 2014, over 11 years ago
Updated 9 July 2025, 23 days ago

The docs say:

> * - 'queue name': The name of the queue to use to queue this task. Must
* contain a valid queue name, declared by hook_cron_queue_info().
* If queue name is given, worker callback will be ignored.

AFAICT this is wrong on two counts.

1.

/**
 * Implements hook_cron_queue_info().
 *
 * Provide queue worker information for jobs declared in
 * hook_cron_job_scheduler_info().
 */
function job_scheduler_cron_queue_info() {
  $queue = array();
  foreach (job_scheduler_info() as $name => $info) {
    if (!empty($info['jobs']) && !empty($info['queue name'])) {
      $queue[$info['queue name']] = array(
        'worker callback' => 'job_scheduler_cron_queue_worker',
        'time' => 60, // Some reasonable default as we don't know
      );
    }
  }
  return $queue;
}

This hook implementation seems to be taking care of declaring queues to Drupal core, based on hook_cron_job_scheduler_info().

This contradicts this statement:

> Must contain a valid queue name, declared by hook_cron_queue_info().

There is the matter that hook_cron_queue_info() skips a scheduler if it has no 'jobs' property. However, AFAICT, if a scheduler info has no jobs, then job_scheduler_rebuild_scheduler() doesn't write anything to the database anyway.

2.

> If queue name is given, worker callback will be ignored

If a queue name is given, then when the scheduler runs, it doesn't execute the worker callback. Instead, it queues a new item in the Drupal queue.

This uses the queue callback job_scheduler_cron_queue_worker(). job_scheduler_cron_queue_worker() executes the job, and executing the job calls the job's worker callback!

So that bit of the docs is wrong too.

🐛 Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024