What a fart on… That’s the only way importing phpBB into bbPress can be described.
Thankfully, however, I finally managed to figure it out & in this post, I’m going to show you exactly how to do it.
So if you’ve been struggling with the import due to errors about missing database columns/fields or finding that the import just simply stalls at a random point then be sure to keep on reading as this information should hopefully help you out.
And it’ll also hopefully save you from pulling all of your hair out (like I did 🤣).
Problem #1
If you’re running a newer version of phpBB & you’ve tried to import your site into bbPress or BuddyBoss then you’ll have probably got some errors mentioning that certain columns are missing from the database, such as “user_website“, “forum_topics“, “topic_replies” and more.
This is because after version ~3.0.4 of phpBB, some columns were dropped from the database & the structure was rejigged a little. It seems the bbPress importer hasn’t been updated since the date of that change, meaning it’s essentially not compatible with newer versions.
(update: for users of phpBB 3.2.2 I found this code that should work & let you import: https://gist.github.com/pixelnated/5c27a64c450578440554ba902560178f)
Now, the best fix here is to create a duplicate of your site & downgrade or upgrade accordingly to a version that works with the bbPress importer (I recommend phpBB 3.0.3, which is what I used).
I upgraded my phpBB2 forum to phpBB 3.0.3, then 3.0.3 -> bbPress (with some additional tweaks that I’ll mention further down in this blog post).
An alternative method, however, is to simply create the columns yourself.
So as an example, if you’re running a later version of phpBB such as phpBB 3.3.0 then you can add the missing columns to “get around” the error. This will allow the import to complete, but by going down this route rather than upgrading/downgrading your board accordingly, you may run into problems with discussions & threads not tieing in properly.
To save you the hassle of figuring out what columns are missing, I made a note of them. Here are the columns you’ll need to add:
ALTER TABLE `phpbb3_users` ADD `user_website` VARCHAR(250) NULL AFTER `user_reminded_time`; ALTER TABLE `phpbb3_users` ADD `user_aim` VARCHAR(250) NULL AFTER `user_website`; ALTER TABLE `phpbb3_users` ADD `user_yim` VARCHAR(250) NULL AFTER `user_aim`; ALTER TABLE `phpbb3_users` ADD `user_icq` VARCHAR(250) NULL AFTER `user_yim`; ALTER TABLE `phpbb3_users` ADD `user_msnm` VARCHAR(250) NULL AFTER `user_icq`; ALTER TABLE `phpbb3_users` ADD `user_occ` VARCHAR(250) NULL AFTER `user_msnm`; ALTER TABLE `phpbb3_users` ADD `user_interests` VARCHAR(250) NULL AFTER `user_occ`; ALTER TABLE `phpbb3_users` ADD `user_from` VARCHAR(250) NULL AFTER `user_interests`; ALTER TABLE `phpbb3_forums` ADD `forum_topics` VARCHAR(250) NULL AFTER `prune_shadow_next`; ALTER TABLE `phpbb3_forums` ADD `forum_posts` VARCHAR(250) NULL AFTER `forum_topics`; ALTER TABLE `phpbb3_forums` ADD `topic_replies` VARCHAR(250) NULL AFTER `forum_posts`; ALTER TABLE `phpbb3_forums` ADD `forum_topics_real` VARCHAR(250) NULL AFTER `topic_replies`; ALTER TABLE `phpbb3_topics` ADD `topic_replies` VARCHAR(250) NULL AFTER `topic_posts_softdeleted`; ALTER TABLE `phpbb3_topics` ADD `topic_replies_real` VARCHAR(250) NULL AFTER `topic_replies`;
I just set them all to null varchar fields & tested it, the installer ran until completion without passing any errors about columns.
Problem #2
It’s possible that you might get really lucky. You might follow the steps outlined above, run the installer & find that your board gets imported successfully.
However, you may also find that the importer gets to a certain point & then just hangs. That’s exactly what happened with me.
At first, I couldn’t for the life of me figure out why it was failing because the importer window wasn’t throwing up any errors at all… It just literally wasn’t doing anything (even though it said it was).
So I headed to the DB to see which record it got up to… Then I went back to my phpBB to see which was record was due to come next (which was the record it clearly had a problem with).
The post_text column for the offending row was full of bbcode & special characters, which was reassuring because that meant that hopefully, the problem would be relatively easy to fix.
Anyway, to cut a long story short… I managed to find the issues. The issues were actually to do with the bbcode, and how the importer attempts to convert the bbcode back to normal HTML.
In the instances were bbcode was formatted correctly, e.g as follows:
[img]http://www.domain.com/image.jpg[/img]
The importer would run fine… But if the bbcode was improperly formatted, such as double tags, missing closing tags etc, it would cause the importer to fail.
Now, there are obviously a handful of different ways to fix this, but it all depends on how perfectly you want your forum to import. Personally, as long as I could preserve in-post images, I wasn’t too bothered about losing font formatting tags etc.
Update: I decided I wanted to keep formatting, so I wrote a better function which you can see here.
So as a result, I wrote a little function which removed ALL bbcode from posts, as shown below:
function cleantext($the_text) { // Remove bracketed text $the_text = preg_replace("/\[.*?\]+/", "", $the_text); return $the_text; }
So all you need to do is run a while{} query on all of your phpBB posts & run that function on them then reinsert them back into the database ready for the import. That’ll remove any bbcode (well, anything in square brackets – including the brackets, really).
Now, if like me you also want to preserve your in-post images then you can use this other little function that I wrote which detects image URLs in the post text & wraps properly formatted bbcode tags around them:
function codeimageURLs($the_text) { preg_match_all('/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/', $the_text, $links); foreach (array_unique($links[0]) as $link) { $ext = strtolower(pathinfo(parse_url($link, PHP_URL_PATH), PATHINFO_EXTENSION)); if (($ext == "jpg") || ($ext == "jpeg") || ($ext == "gif") || ($ext == "png")) { $the_text = str_replace($link, "[img]".$link."[/img]", $the_text); } } return $the_text; }
So use the cleantext() function to remove all tags, then use the codeimageURLs() to wrap linked images back in their tags.
Again, just do it in a while{} query & resubmit them back into your database ready for import.
Once done, your import should run smoothly.
Additional Notes
If your images do not wrap back into tags properly, it may be because the links have been formatted in your phpBB database so the function doesn’t detect them. To fix this, use the following function with some additional lines before using the function to add image tags:
function cleantext($the_text) { // Remove bracketed text $the_text = preg_replace("/\[.*?\]+/", "", $the_text); $the_text = str_replace(":", ":", $the_text); $the_text = str_replace(".", ".", $the_text); return $the_text; }
If you run into any additional issues, it may be because of special characters. To fix this, find the last record where the importer stopped, then look for the one after it in the phpBB database.
Does it contain special characters?
If so, simply include the special characters into the cleantext() function, like so (using the example of an asterisk being the special character causing the problems):
function cleantext($the_text) { // Remove bracketed text $the_text = preg_replace("/\[.*?\]+/", "", $the_text); $the_text = str_replace(":", ":", $the_text); $the_text = str_replace(".", ".", $the_text); $the_text = str_replace("*", "", $the_text); return $the_text; }
The Bottom Line
Hopefully this post helps you because honestly, I was getting super frustrated with it & there just seemed to be a total lack of helpful information anywhere to be found.
If, however, you still find yourselves having problems then don’t hesitate to leave a comment & I’ll do my best to help you out.