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
Comment #1
tmetzger commentedLet me add that "gclient_sync()" calls xml-rpc to grab some data from a remote site. I wonder if this is possible??
Comment #2
kenorb commented