Batch operation not called I am trying to write a Batch import to create nodes based on a uploaded file. The form works and I receive the file, and can read it in my submit callback which should initiate the Batch import. Here is the code:

function mymodule_import_submit(&amp;$form, $form_state) {
  $xml = file_get_contents($form_state['values']['xml']-&gt;uri);

  $ads = xml2ary($xml);

  $batch = array(
    'title' =&gt; t('Importing Content ...'),
    'operations' =&gt; array(),
    'init_message' =&gt; t('Commencing'),
    'progress_message' =&gt; t('Processed @current out of @total.'),
    'error_message' =&gt; t('An error occurred during processing'),
    'finished' =&gt; 'mymodule_import_finished',
  );

  foreach ($nodes['nodes']['_c']['node'] as $new_node) {
    $batch['operations'][] = array('mymodule_import_create_node', array($new_node['_c'])); 
  }

  batch_set($batch);
}


While it seems to know the amount of operations needed (how many need to be created) my callback doesn't seem to get called. Here is its code:

function mymodule_import_create_node($new_node) {
  $clean_body = make_safe($new_node['CONTENT_BODY']['_v']);

  $node = new stdClass();
  $node-&gt;type = 'article';
  node_object_prepare($node);

  $node-&gt;title = substr(strip_tags($clean_body, 0, 20)) . '...';
  $node-&gt;body['und'][0]['value'] = $clean_body;
  $node-&gt;status = 1;
  $node-&gt;field_article_category = array();
  $node-&gt;field_article_location = '';
  $node-&gt;field_email_address = '';
  $node-&gt;uid = 1;

  node_save($node);

  $context['results']['articles_imported']++;
}


I put a few dumps at the start of the batch callback and it never exits. Watchdog indicates nothing, and no new nodes appear.
According to the Batch operations page on api.drupal.org, the processing function needs to have $context passed by reference.

Thus your import create node function should read function mymodule_import_create_node($node, &amp;$context) and that should do it

Edit: sample code