# phpBB 3 Importer (old)

**URL:** https://meta.discourse.org/t/phpbb-3-importer-old/17397
**Category:** Feature
**Created:** [July 9, 2014, 6:57pm UTC](https://meta.discourse.org/t/phpbb-3-importer-old/17397 "2014-07-09T18:57:02Z")
**Posts on this page:** 11
**Page:** 5

<div class="post-metadata">

### Author: ![Jeff\_Vienneau](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeff_vienneau/32/108772_2.png) [@Jeff\_Vienneau](https://meta.discourse.org/u/Jeff_Vienneau)
#### Post date: [October 6, 2014, 10:57pm UTC](https://meta.discourse.org/t/phpbb-3-importer-old/17397/82 "2014-10-06T22:57:49Z")

</div>

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

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [October 6, 2014, 11:02pm UTC](https://meta.discourse.org/t/phpbb-3-importer-old/17397/83 "2014-10-06T23:02:00Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [October 6, 2014, 11:44pm UTC](https://meta.discourse.org/t/phpbb-3-importer-old/17397/84 "2014-10-06T23:44:36Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [October 7, 2014, 9:19pm UTC](https://meta.discourse.org/t/phpbb-3-importer-old/17397/85 "2014-10-07T21:19:05Z")

</div>

[I added code to the phpbb3 importer to support attachments](https://github.com/discourse/discourse/commit/cea2fe5ee9e2e89a32377c0af23de60a42a77482).

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.

> [@elberet](#):
>
> Discourse has a utility function that generates the proper and localized HTML markup for an uploaded file, but this is implemented in JavaScript.

I used a hacky solution to this too… so, there’s room for improvement. 😊

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [October 7, 2014, 9:48pm UTC](https://meta.discourse.org/t/phpbb-3-importer-old/17397/86 "2014-10-07T21:48:53Z")

</div>

@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.

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [October 7, 2014, 10:03pm UTC](https://meta.discourse.org/t/phpbb-3-importer-old/17397/87 "2014-10-07T22:03:22Z")

</div>

That’s right. It won’t bump the topic to the top of topic lists.

---

<div class="post-metadata">

### Author: ![Jeff\_Vienneau](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeff_vienneau/32/108772_2.png) [@Jeff\_Vienneau](https://meta.discourse.org/u/Jeff_Vienneau)
#### Post date: [October 8, 2014, 3:59pm UTC](https://meta.discourse.org/t/phpbb-3-importer-old/17397/88 "2014-10-08T15:59:55Z")

</div>

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/](http://oldsite.net/forum/download/)”

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [October 8, 2014, 4:14pm UTC](https://meta.discourse.org/t/phpbb-3-importer-old/17397/89 "2014-10-08T16:14:19Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![kuchaev\_iv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kuchaev_iv/32/114921_2.png) [@kuchaev\_iv](https://meta.discourse.org/u/kuchaev_iv)
#### Post date: [October 8, 2014, 7:52pm UTC](https://meta.discourse.org/t/phpbb-3-importer-old/17397/90 "2014-10-08T19:52:45Z")

</div>

> [@michaeld](#):
>
> this is also handy for feeding into a SEO redirection script which we put in place instead of the old forum

Where can I find that script?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 8, 2014, 9:17pm UTC](https://meta.discourse.org/t/phpbb-3-importer-old/17397/91 "2014-10-08T21:17:59Z")

</div>

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

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 8, 2014, 9:18pm UTC](https://meta.discourse.org/t/phpbb-3-importer-old/17397/92 "2014-10-08T21:18:02Z")

</div>



[Previous page](https://meta.discourse.org/t/phpbb-3-importer-old/17397.md?page=4)
