I am struggeling converting my old PHPBB forum to drupal using the HEAD version of phpbb2drupal.

Converting users and topics runs fine, but when trying to convert the posts (there is a large number of posts) my page goes blank after just 7 seconds. When trying backspace and run again, it reports that a large number is already imported but on susequent attempts to import posts it still times out. Apparently not all posts are imported when I check the forum afterwards. Any clues anyone?

/Sten

Comments

arkepp’s picture

Change the PHP timeout setting in Apache's php.ini. If you can't do that you may have to play around with the code to make it do batches of 5000 or so. (sorry, I know that's probably not what you wanted to hear, you could post it as a feature-request for the module maintainer)

stenjo’s picture

I have been playing around with the code and have made it echo a period while inside relevant loops. This sort of fixed the problem, although I'm getting a new error (headers already sent).
It'll get me started all right...

/Sten

Cross_and_Flame’s picture

Hey, running into the same problem with the timeouts and blank screen. Mind sharing your code changes to keep it from happening?

Thanks a million!

stenjo’s picture

Basically I added some dummy echo statements to make the script output something while it was working, preventing the browser, or whatever, to time out during operation.
And if it did not work, at least I knew where the script failed.

Can't se how to attach code, so I include som example statements added:
From approx. line 919 I modified the code to list:

  db_set_active('default');
  while ($pm = db_fetch_object($messages)) {    
  	
  	// Debug
	$icounter++;
	echo ".";	// Debug output to avoid browser timing out...
	if (!($icounter %= 80))
		echo "<br>"." ";
	// End Debug

    $query = 'SELECT uid FROM {phpbb2drupal_temp_user} WHERE user_id = %d';
    $from_result = db_query($query, $pm->privmsgs_from_userid);
    $from = db_result($from_result);

And between line

  $import_spammers = variable_get('phpbb2drupal_import_spammers', 1);

and

    db_set_active('phpbb');

at approx. line 1000 I inserted:

  
	$icounter=0;
  while ($result = db_fetch_object($user_ids)) {    
  	// Debug
	$icounter++;
	echo ".";	// Debug output to avoid browser timing out...
	if (!($icounter %= 180))
		echo "<br>"." ";
	// End Debug

... and so on.
Place listouts of this kind anywhere you wish - typically inside while loops and repeating code that is expected to take some time...

When running the module with these changes, I can see if there are any activities and if the script is behaving as expected.
I always get an "Headers alredy sent" error, but that is to be expected I assume...

/Sten

Cross_and_Flame’s picture

Thanks for your help. I've played with it and it helps keep the process going for all the imports.

However, when we get to the realllllly long part (importing posts), I can't seem to place it in the right section, as it still ceases to import after a certain limit. Is there a section in the "import post" section of the code that you can offer as another example?

Thanks again. This is very helpful.

eternal21’s picture

>>Is there a section in the "import post" section of the code that you can offer as another example?

To avoid "Import Posts" from timing out you can place the debug code like this:

(this is around line 728)

while ($result = db_fetch_object($post_ids)) {
      $loops++;

     // Debug
          $icounter++;
          echo "."; // Debug output to avoid browser timing out...
          if (!($icounter %= 180))
          echo "<br>"." ";
     // End Debug

Also if you were unlucky enough to start importing, and timing out, some of the posts will already be imported, and you'll end up with duplicates. Not only that - the module won't let you retry the import.

The workaround is to first Empty the drupal_comments table (it will remove all other comments, so this only should be done on installs where you don't care about losing comments (fresh installs)). On top of that you'll have to comment out the return; in the phpbb2drupal.module here (around line 692):

db_set_active('default');
  // check if the post database has been successfully imported
  if (variable_get('phpbb2drupal_import_post_successful', 0)) {
    drupal_set_message(t('Posts already imported successfully'));
    //return;
  }