From 54d450156f197d9fb459a02ff01291a3a2addacf Mon Sep 17 00:00:00 2001 From: Stefan Tatschner Date: Fri, 14 Nov 2014 14:26:13 +0100 Subject: [PATCH 1/3] Remove mybb video tags mybb embedds videos like this: [video=provider]http://link-to-video.com[/video] Let's remove these video tags as discourse does this automatically. --- script/import_scripts/mybb.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script/import_scripts/mybb.rb b/script/import_scripts/mybb.rb index 4ec4c88a3..3f7e70e5d 100644 --- a/script/import_scripts/mybb.rb +++ b/script/import_scripts/mybb.rb @@ -150,6 +150,9 @@ class ImportScripts::MyBB < ImportScripts::Base # [quote="cybereality":b0wtlzex]Some text.[/quote:b0wtlzex] s.gsub!(/:(?:\w{8})\]/, ']') + # Remove mybb video tags. + s.gsub!(/(^\[video=.*?\])|(\[\/video\]$)/, '') + s = CGI.unescapeHTML(s) # phpBB shortens link text like this, which breaks our markdown processing: From 2ffd3d29d755c3f50e161b140471fc24c3b9f718 Mon Sep 17 00:00:00 2001 From: Stefan Tatschner Date: Fri, 14 Nov 2014 14:28:09 +0100 Subject: [PATCH 2/3] Order posts by dateline The post_ids in my mybb installation did not be in the right order. Post with ID 2 was posted after post 5. I think it has something to do with a previous import from phpbb to mybb. --- script/import_scripts/mybb.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/import_scripts/mybb.rb b/script/import_scripts/mybb.rb index 3f7e70e5d..753910c76 100644 --- a/script/import_scripts/mybb.rb +++ b/script/import_scripts/mybb.rb @@ -94,7 +94,7 @@ class ImportScripts::MyBB < ImportScripts::Base FROM mybb_posts p, mybb_threads t WHERE p.tid = t.tid - ORDER BY id + ORDER BY p.dateline LIMIT #{BATCH_SIZE} OFFSET #{offset}; ") From 3fdda8c2b7c0b58459ea64f8a5e0f0a35dfa5179 Mon Sep 17 00:00:00 2001 From: Stefan Tatschner Date: Fri, 14 Nov 2014 14:41:34 +0100 Subject: [PATCH 3/3] Retrieve first_post_id manually I had imported a phpbb forum to mybb previously. The importer script messed up the firstpost ids. In this case most topics cannot be imported to discourse as the script is not able to determine the topic post. In case you are infected of this problem just uncomment this mysql query. It will retrieve the first_post_id manually but it will slow down the import. --- script/import_scripts/mybb.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/script/import_scripts/mybb.rb b/script/import_scripts/mybb.rb index 753910c76..224174843 100644 --- a/script/import_scripts/mybb.rb +++ b/script/import_scripts/mybb.rb @@ -105,6 +105,20 @@ class ImportScripts::MyBB < ImportScripts::Base skip = false mapped = {} + # If you have imported a phpbb forum to mybb previously there might + # be a problem with mybb_threads.firstpost. If these ids are wrong + # the thread cannot be imported to discourse as the topic post is + # missing. This query retrieves the first_post_id manually. As it + # will decrease the performance it is commented out by default. + # m['first_post_id'] = mysql_query(" + # SELECT p.pid id, + # FROM mybb_posts p, + # mybb_threads t + # WHERE p.tid = #{m['topic_id']} AND t.tid = #{m['topic_id']} + # ORDER BY p.dateline + # LIMIT 1 + # ").first['id'] + mapped[:id] = m['id'] mapped[:user_id] = user_id_from_imported_user_id(m['user_id']) || -1 mapped[:raw] = process_mybb_post(m['raw'], m['id'])