Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Functions background_process_queue_locked and background_process_queue expect that the BackgroundProcess::queue() method will return a handle or at least non null and non false value. But when you look at that method it does not return a value at all if there was no error:
public function queue($callback, $args = array()) {
if (!$this->lock(BACKGROUND_PROCESS_STATUS_QUEUED)) {
return FALSE;
}
$this->callback = $callback;
$this->args = $args;
if (!background_process_set_process($this->handle, $this->callback, $this->uid, $this->args, $this->token)) {
// Could not update process
return NULL;
}
module_invoke_all('background_process_pre_execute', $this->handle, $this->callback, $this->args, $this->token);
// Initialize progress stats
$old_db = db_set_active('background_process');
progress_remove_progress($this->handle);
db_set_active($old_db);
$queues = variable_get('background_process_queues', array());
$queue_name = isset($queues[$this->callback]) ? 'bgp:' . $queues[$this->callback] : 'background_process';
$queue = DrupalQueue::get($queue_name);
$queue->createItem(array(rawurlencode($this->handle), rawurlencode($this->token)));
_background_process_ensure_cleanup($this->handle, TRUE);
// It should return value here!
}
Comments
Comment #1
SiliconMind CreditAttribution: SiliconMind commentedComment #2
SiliconMind CreditAttribution: SiliconMind commentedNote, that because of this you can't tell if process was queued correctly. That's because the
BackgroundProcess::queue()
returns null or false when there is a failure. The return value should be consistent and in case of failure should equal to false to avoid confusion.