I have decided to separate this issue out from the port to Drupal 6 issue.

Currently the module uses a default ini_set of 1200 seconds to avoid timing out when importing data. There are still time outs. The answer should be to use the new batch api introduces in Drupal 6. "Should be" because I am finding it trickier to do than I probably should.

Attached is a patch to batch import the users. I have tried a few different ways, but nothing seems to work. Worse, I do not know what I am doing wrong.

The only place I can think of which may be wrong is the query to get the user id's:

$user_ids = db_query_range('SELECT user_id FROM %susers WHERE user_id > 2 ORDER BY user_id', $pre, $context['sandbox']['user_row'], $limit);

Any input will be helpful.

CommentFileSizeAuthor
phpbb2drupal_batch.patch3.3 KBnaheemsays

Comments

naheemsays’s picture

I think I should qualify "nothing seems to work".

What happens, the batch operation starts, says "2 users processed", finishes a few seconds later and says 1 user imported.

It seems the batch (or the "while" loop) loops just twice instead of how ever many users there are. (the final tally is not from the score kept, but by reading the phpbb2drupal_temp_users table.)

I have also previously tried a different approach where the while loop,is outside the batch operation similar to:

while $result = db_fetch_object($user_ids) {

$operations = phpbb2drupal_batch_import_users, array ($result)

}
 
$batch = array(
  'operations' => array($operations),
  'finished' => 'phpbb2drupal_batch_import_users_finished',
  'title' => t('Migrating Users'),
  'init_message' => t('User import is starting.'),
  'progress_message' => t('@current users processes.'),
  'error_message' => t('User import has encountered an error.'),
);
batch_set($batch);

But this caused an OOM as (I think) there were too many operations (one for each user). Additionally, I do not expect that code to work... I would expect it to load the same user over and over again.

andypost’s picture

I'm going to test this

naheemsays’s picture

The patch on this issue is probably useless. I never had much understanding of batch API.

andypost’s picture

Patch does not working, I start to rework it.

My current project has 6k topics and 120k comments so without batch it's not possible to convert it.

Also I'm trying to add some kind of incremental updates if I could :)

meustrus’s picture

I see that you define a variable $user_count but add to $batch['progress']['max'] = $usercount

shadcn’s picture

Any progress on this?

JeremyFrench’s picture

Status: Active » Closed (fixed)

The module now uses migrate API which in turn uses batch api.