# MyBB import doesn't process on quoted posts PID and date

**URL:** https://meta.discourse.org/t/mybb-import-doesnt-process-on-quoted-posts-pid-and-date/27412
**Category:** Bug
**Created:** [10 april 2015 om 09:39 UTC](https://meta.discourse.org/t/mybb-import-doesnt-process-on-quoted-posts-pid-and-date/27412 "2015-04-10T09:39:10Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![dandv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dandv/32/169779_2.png) [@dandv](https://meta.discourse.org/u/dandv)
#### Post date: [10 april 2015 om 09:39 UTC](https://meta.discourse.org/t/mybb-import-doesnt-process-on-quoted-posts-pid-and-date/27412/1 "2015-04-10T09:39:10Z")

</div>

Much [like Vanilla Porter](https://github.com/vanilla/porter/issues/61), the Discourse [MyBB import script](https://github.com/discourse/discourse/blob/master/script/import_scripts/mybb.rb) doesn’t process on quoted posts the PID (to link to the original post) and date (it’s left in seconds-since-epoch format).

MyBB: [https://forum.quantifiedself.com/thread-zeo-shutting-down-export-your-data?pid=2638#pid2638](https://forum.quantifiedself.com/thread-zeo-shutting-down-export-your-data?pid=2638#pid2638)  
Discourse: [http://discourse.quantifiedselfforum.com/t/zeo-shutting-down-export-your-data/561/6](http://discourse.quantifiedselfforum.com/t/zeo-shutting-down-export-your-data/561/6)

---

<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: [10 april 2015 om 18:09 UTC](https://meta.discourse.org/t/mybb-import-doesnt-process-on-quoted-posts-pid-and-date/27412/2 "2015-04-10T18:09:47Z")

</div>

This looks similar to SMF2’s quote syntax. You could copy my somewhat over-engineered solution from the SMF2 importer… 😄

---

<div class="post-metadata">

### Author: ![dandv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dandv/32/169779_2.png) [@dandv](https://meta.discourse.org/u/dandv)
#### Post date: [20 september 2015 om 03:27 UTC](https://meta.discourse.org/t/mybb-import-doesnt-process-on-quoted-posts-pid-and-date/27412/3 "2015-09-20T03:27:54Z")

</div>

@elberet: Unfortunately I don’t speak Ruby and am not familiar with the Discourse internals and [DB schema](https://meta.discourse.org/t/database-diagram-for-tables-keys-columns-etcetera-in-discourse/3947), and [the SMF importer](https://github.com/discourse/discourse/blob/master/script/import_scripts/smf2.rb) is quite different from [the MyBB one](https://github.com/discourse/discourse/blob/master/script/import_scripts/mybb.rb) (I guess the magic is in the [`MessageDependencyGraph` class](https://github.com/discourse/discourse/blob/master/script/import_scripts/smf2.rb#L582)).

Could you point me towards how, for starters, to patch the MyBB script to convert the date in the quote line?

Also, how practical would it be to just go ahead with the migration, and later patch the quote line in the imported posts?

---

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [20 september 2015 om 08:01 UTC](https://meta.discourse.org/t/mybb-import-doesnt-process-on-quoted-posts-pid-and-date/27412/4 "2015-09-20T08:01:06Z")

</div>

> [@elberet](#):
>
> You could copy my somewhat over-engineered solution from the SMF2 importer…

Can you elaborate on what you are doing there? For us, it has never worked, it always gives a ‘recursion too deep’ error and then crashes.

---

<div class="post-metadata">

### Author: ![dandv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dandv/32/169779_2.png) [@dandv](https://meta.discourse.org/u/dandv)
#### Post date: [22 september 2015 om 05:16 UTC](https://meta.discourse.org/t/mybb-import-doesnt-process-on-quoted-posts-pid-and-date/27412/5 "2015-09-22T05:16:16Z")

</div>

I’ve looked some more into this. The quote syntax for MyBB is:

```plaintext
[quote='username' pid='1234' dateline='1412029545']
...
[/quote]

```

In Discourse, it’s

```plaintext
[quote="username, post:12, topic:1234"]
...
[/quote]

```

How can I [get the post number and topic ID from the post ID](https://meta.discourse.org/t/searching-for-the-topic-post-by-id/19084/), via the API? [process\_mybb\_post](https://github.com/discourse/discourse/blob/master/script/import_scripts/mybb.rb#L156) would need to be updated to take that into account; BTW, the `import_id` parameter isn’t used.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [22 september 2015 om 05:17 UTC](https://meta.discourse.org/t/mybb-import-doesnt-process-on-quoted-posts-pid-and-date/27412/6 "2015-09-22T05:17:28Z")

</div>

You want to call `post_id_from_imported_post_id` from the import script.

---

<div class="post-metadata">

### Author: ![dandv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dandv/32/169779_2.png) [@dandv](https://meta.discourse.org/u/dandv)
#### Post date: [22 september 2015 om 06:21 UTC](https://meta.discourse.org/t/mybb-import-doesnt-process-on-quoted-posts-pid-and-date/27412/7 "2015-09-22T06:21:32Z")

</div>

> [@riking](#):
>
> You want to call `post_id_from_imported_post_id` from the import script.

That seems to [return only one id](https://github.com/discourse/discourse/blob/e265d8af5ddb52e871b2f981a73fc8d51d355bcc/script/import_scripts/base/lookup_container.rb#L46). Don’t we need the post number within the topic (not its id), and the topic id?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [22 september 2015 om 06:23 UTC](https://meta.discourse.org/t/mybb-import-doesnt-process-on-quoted-posts-pid-and-date/27412/8 "2015-09-22T06:23:55Z")

</div>

Well, you can pass that to `Post.find(id)` and get the `post_number` and `topic_id` out from that.

---

<div class="post-metadata">

### Author: ![dandv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dandv/32/169779_2.png) [@dandv](https://meta.discourse.org/u/dandv)
#### Post date: [22 september 2015 om 12:37 UTC](https://meta.discourse.org/t/mybb-import-doesnt-process-on-quoted-posts-pid-and-date/27412/9 "2015-09-22T12:37:37Z")

</div>

Thanks @riking. I’ve sent [a PR](https://github.com/discourse/discourse/pull/3802).

Now how could I run just that replacement on existing posts?

@elberet: my approach is far simpler. Would you mind taking a look?

---

<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: [21 juli 2022 om 05:26 UTC](https://meta.discourse.org/t/mybb-import-doesnt-process-on-quoted-posts-pid-and-date/27412/10 "2022-07-21T05:26:01Z")

</div>


