I am trying to write a batch. And I have a problem that none of the batch operations callback functions are getting called.
I wrote drupal_set_message
at the start of each callback and none of the messages are displayed.
I can get the batch page, but the callback ops aren't called at all.
Here's the code I used:
function mymdoule_node_batch()
{
$batch = array(
'title' => t("Migrating"),
'operations' => array(
array('mycallback_001'),
array('mycallback_002'),
),
'finished' => 'mycallback_finished',
'init_message' => t('Initializing...'),
'error_message' => t('An error occurred.'),
);
batch_set($batch);
drupal_set_message("step: 0"); // this is the only message the system returns
}
function mycallback_001(&$context)
{
drupal_set_message("step: 1");
$nids = db_select("node", "n")
->fields("n", array("nid"))
->orderBy("nid", "ASC")
->execute()
->fetchCol();
}
function mycallback_002(&$context)
{
drupal_set_message("step: 2");
$nids = db_select("node", "n")
->fields("n", array("nid"))
->orderBy("nid", "ASC")
->execute()
->fetchCol();
}
P.s. The batch is getting called in form submission.
What's wrong in that?
add one redirection at the end of mymdoule_node_batch
? Can you provide a code sample?batch_process();
beforedrupal_set_message("step: 0");
the message is not displayed as well.