# 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:** [April 10, 2015, 9:39am 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

## AI-generated summary

The MyBB import script in Discourse doesn't process quoted posts' PID and date correctly. [dandv](/t/-/27412/1) and [elberet](/t/-/27412/2) discussed possible solutions, with [elberet](/t/-/27412/2) suggesting copying his solution from the SMF2 importer. However, [dandv](/t/-/27412/3) is not familiar with Ruby and the Discourse internals.

[dandv](/t/-/27412/5) identified the issue as a difference in quote syntax between MyBB and Discourse, and asked how to retrieve the post number and topic ID from the post ID via the API. [riking](/t/-/27412/6) suggested calling `post_id_from_imported_post_id` from the import script, but [dandv](/t/-/27412/7) noted that this only returns one ID.

[riking](/t/-/27412/8) advised passing the ID to `Post.find(id)` to get the `post_number` and `topic_id`. [dandv](/t/-/27412/9) created a pull request with a simpler approach and asked [elberet](/t/-/27412/9) to review it.

<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:** [April 10, 2015, 9:39am 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:** [April 10, 2015, 6:09pm 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:** [September 20, 2015, 3:27am 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:** [September 20, 2015, 8:01am 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:** [September 22, 2015, 5:16am 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:** [September 22, 2015, 5:17am 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:** [September 22, 2015, 6:21am 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:** [September 22, 2015, 6:23am 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:** [September 22, 2015, 12:37pm 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:** [July 21, 2022, 5:26am UTC](https://meta.discourse.org/t/mybb-import-doesnt-process-on-quoted-posts-pid-and-date/27412/10 "2022-07-21T05:26:01Z")

</div>

Closed on July 21, 2022, 5:26am UTC


