phpBB 3 Importer (old)

I was looking in imports/base.rb as well.

AFAIK its only implemented for SMF2 (thanks to @elberet)
I havenā€™t looked into it yet, but I guess parts of it could be moved to the base importer and be reused for phpBB.

Iā€™ve placed the Discourse-specific part of that code into ImportScripts::Base#create_upload.

The method expects, in order, the uploaderā€™s Discourse user id, the current path of the file and the original filename; before handing the file over to Discourse, it creates a temporary copy of the uploaded file, so the source data is guaranteed to remain undisturbed. The return value is the Discourse model object representing the upload.

The real magic happens in ImportScripts::Smf2#convert_message_body, but this part is very much specific to the import source. There is one bit that may be of interest to others working on importers: #get_upload_markdown and #v8, which is mostly lifted from Discourseā€™s PrettyText module. Discourse has a utility function that generates the proper and localized HTML markup for an uploaded file, but this is implemented in JavaScript.

Unfortunately, that bit of code is rather hacky, as evidenced by the recently reported problems other users had with getting attachments imported properly ā€“ so moving it into the importer base may not be a good idea.

1 Like

I added code to the phpbb3 importer to support attachments.

To use it, youā€™ll need to edit at least one constant near the top of the script: ATTACHMENTS_BASE_DIR and possibly AUTHORIZED_EXTENSIONS. In my case, I was given a big tar.gz file with all the attachments, so I extracted them somewhere, set ATTACHMENTS_BASE_DIR to that directory, and most of the attachments imported successfully.

Some attachments fail to import because of this error:

Couldn't find phpbb_attachments record for post.id = 9876, import_id = 9123, real_filename = blahblah.jpg

In those cases, the phpbb_attachments table really is missing records for those attachments, so thereā€™s no way to import them. Maybe your phpbb databases wonā€™t have this problem.

I used a hacky solution to this tooā€¦ so, thereā€™s room for improvement. :blush:

5 Likes

@neil Can you confirm the following for me? I notice you used the following line:

PostRevisor.new(post).revise!(post.user, new_raw, {bypass_bump: true, edit_reason: 'Migrate from PHPBB3'})

Specifically bypass_bump: true - does this absolutely not bump the topic at all?

I donā€™t want users getting any kind of notification from my reprocessing of posts.

Thatā€™s right. It wonā€™t bump the topic to the top of topic lists.

1 Like

Thank you so much for this, @neil!

Can ATTACHMENTS_BASE_DIR be a remote directory or should I ftp the files across to the new site?:

ā€œhttp://oldsite.net/forum/download/ā€

Itā€™s a local directory. Being able to download the files during the import would be pretty fancy, but I was given a tar file.

Where can I find that script?

Read the first post, this is now complete. Open new support topics for support on this.