I lost a couple of hours because I wrote this:

$operations[] = array('callback_function');
$batch['operations'] = $operations;

Instead of this:

$operations[] = array('callback_function', array());
$batch['operations'] = $operations;

And couldn't work out why my batch operation was only being called once despite setting $context['finished'] = 0.5 in the callback function.

Turns out, if you omit the array() parameter, the $context variable passed to the callback function will be uninitialised. Attached is a simple patch that would detect this situation and make the array of arguments in the operation definition optional if none are required.

CommentFileSizeAuthor
batch-operation-optional-args.patch482 bytesDraknek
Support from Acquia helps fund testing for Drupal Acquia logo