Hi all
I am trying to update the phpbb2drupal module to use the batch api for drupal 6, but well, not succeeding.
I have issue open at http://drupal.org/node/218966 where I am tracking this, but would love extra eyes as I am stumped. There is a patch in that queue to change the user import function (phpbb2drupal_import_users) to the batch API, but I cannot get it to work.
Just to simplify that patch, what I have done is something like changing this original code:
...
$user_ids = db_query('SELECT user_id FROM %susers WHERE user_id > 2 ORDER BY user_id', $pre);
while ($result = db_fetch_object($user_ids)) {
//Do the import stuff here - this is done once per User-id
}
<code>
to:
<code>
if (!isset($context['sandbox']['progress'])) {
$context['sandbox']['progress'] = 0;
$context['sandbox']['user_row'] = 0;
db_set_active('phpbb');
$user_count = db_result(db_query('SELECT COUNT(user_id) FROM %susers WHERE user_id > 2 ORDER BY user_id', $pre));
db_set_active('default');
$context['sandbox']['max'] = $usercount;
}
...
$limit = 5;
$user_ids = db_query_range('SELECT user_id FROM %susers WHERE user_id > 2 ORDER BY user_id', $pre, $context['sandbox']['user_row'], $limit);
while ($result = db_fetch_object($user_ids)) {
//Do import stuff here
$context['sandbox']['progress']++;
$context['sandbox']['user_row']++;
}