2

This is my first time using the DrupalQueue class, and I have two questions.

Does hook_cron_queue_info() HAVE to go in my mymodule.module file? I had some weird behavior before finally trying that, and it seems to be the culprit.

Can I put the queue worker callback in a separate file? I'm trying to keep all my queue functions in their own file, but it doesn't seem like I can do a file attribute like with a lot of other callback types; I just keep getting function undefined errors.

I tried...

function mymodule_cron_queue_info() {
  $queues['autopilot'] = array(
    'time' => 60,
    'worker callback' => '_mymodule_queue_handler',
    'file' => array('type' => 'inc', 'module' => 'mymodule', 'name' => 'includes/mymodule.queue'),
  );
  return $queues;
}

and

function mymodule_cron_queue_info() {
 module_load_include('module', 'mymodule', 'includes/mymodule.queue.inc');
  $queues['autopilot'] = array(
    'time' => 60,
    'worker callback' => '_mymodule_queue_handler',
  );
  return $queues;
}

but neither seem to work.

1 Answer 1

3

I was looking for this too. Turns out that it is not supported, judging from source in drupal_cron_run(). If your queue worker is sizable, one option is to create an intermediary worker callback in your .module file, then include and execute the mymodule.queue.inc worker from that function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.