Merge pull request #2966 from rumpelsepp/mybb_import

Improve Mybb import script
This commit is contained in:
Neil Lalonde 2014-11-14 11:12:34 -05:00
commit 90a28f0e35

View file

@ -94,7 +94,7 @@ class ImportScripts::MyBB < ImportScripts::Base
FROM mybb_posts p, FROM mybb_posts p,
mybb_threads t mybb_threads t
WHERE p.tid = t.tid WHERE p.tid = t.tid
ORDER BY id ORDER BY p.dateline
LIMIT #{BATCH_SIZE} LIMIT #{BATCH_SIZE}
OFFSET #{offset}; OFFSET #{offset};
") ")
@ -105,6 +105,20 @@ class ImportScripts::MyBB < ImportScripts::Base
skip = false skip = false
mapped = {} 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[:id] = m['id']
mapped[:user_id] = user_id_from_imported_user_id(m['user_id']) || -1 mapped[:user_id] = user_id_from_imported_user_id(m['user_id']) || -1
mapped[:raw] = process_mybb_post(m['raw'], m['id']) mapped[:raw] = process_mybb_post(m['raw'], m['id'])
@ -150,6 +164,9 @@ class ImportScripts::MyBB < ImportScripts::Base
# [quote=&quot;cybereality&quot;:b0wtlzex]Some text.[/quote:b0wtlzex] # [quote=&quot;cybereality&quot;:b0wtlzex]Some text.[/quote:b0wtlzex]
s.gsub!(/:(?:\w{8})\]/, ']') s.gsub!(/:(?:\w{8})\]/, ']')
# Remove mybb video tags.
s.gsub!(/(^\[video=.*?\])|(\[\/video\]$)/, '')
s = CGI.unescapeHTML(s) s = CGI.unescapeHTML(s)
# phpBB shortens link text like this, which breaks our markdown processing: # phpBB shortens link text like this, which breaks our markdown processing: