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

AI-generated summary

The MyBB import script in Discourse doesn’t process quoted posts’ PID and date correctly. dandv and elberet discussed possible solutions, with elberet suggesting copying his solution from the SMF2 importer. However, dandv is not familiar with Ruby and the Discourse internals.

dandv 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 suggested calling post_id_from_imported_post_id from the import script, but dandv noted that this only returns one ID.

riking advised passing the ID to Post.find(id) to get the post_number and topic_id. dandv created a pull request with a simpler approach and asked elberet to review it.

Much like Vanilla Porter, the Discourse MyBB import script 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
Discourse: http://discourse.quantifiedselfforum.com/t/zeo-shutting-down-export-your-data/561/6

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

1 Mi Piace

@elberet: Unfortunately I don’t speak Ruby and am not familiar with the Discourse internals and DB schema, and the SMF importer is quite different from the MyBB one (I guess the magic is in the MessageDependencyGraph class).

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?

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.

2 Mi Piace

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

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

In Discourse, it’s

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

How can I get the post number and topic ID from the post ID, via the API? process_mybb_post would need to be updated to take that into account; BTW, the import_id parameter isn’t used.

You want to call post_id_from_imported_post_id from the import script.

1 Mi Piace

That seems to return only one id. Don’t we need the post number within the topic (not its id), and the topic id?

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

Thanks @riking. I’ve sent a PR.

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

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