Been beating my head against a wall on this one. I've got a straightforward batch system to grab info via xml-rpc, but the callback only gets called once even though $context['finished'] returns as a small float, less than 1.

Here's the invocation of the batch:

    $batch = array(
      'operations' => array(
        array( 'gclient_sync_all_batch', array() ),
        ),
      'finished' => 'gclient_sync_all_batch_done',
      'title' => 'Synchronizing Information For All Sites',
      'init_message' => t('Starting up the sync.'),
      'progress_message' => t('Synchronized @current of @total'),
      'error_message' => 'Hit some kind of error',
    );
    batch_set($batch);
    batch_process('gclient');

And here's the callback:

function gclient_sync_all_batch(&$context) {

  if (!isset($context['sandbox']['progress'])) {
    $context['sandbox']['sites'] = gclient_get_sites();
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['max'] = sizeof($context['sandbox']['sites']);

  }

  if( sizeof($context['sandbox']['sites']) ) {

    // if we've got more sites, grab the first site and sync it
    $site = array_shift($context['sandbox']['sites']);
    gclient_sync($site);

    // update progress meter
    $context['sandbox']['progress']++;
    $context['message'] = $site;
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  } else {
    $context['finished'] = 1;
  }
}

Any clues? The callback is supposed to be called repeatedly, right?

Comments

tmetzger’s picture

Let me add that "gclient_sync()" calls xml-rpc to grab some data from a remote site. I wonder if this is possible??

kenorb’s picture

Component: base system » batch system
Category: bug » support

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.