Improvements to phpBB3 import script (#10999)

* FEATURE: Import attachments

* FEATURE: Add support for importing multiple forums in one

* FEATURE: Add support for category and tag mapping

* FEATURE: Import groups

* FIX: Add spaces around images

* FEATURE: Custom mapping of user rank to trust levels

* FIX: Do not fail import if it cannot import polls

* FIX: Optimize existing records lookup

Co-authored-by: Gerhard Schlager <mail@gerhard-schlager.at>
Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
Bianca Nenciu
2021-01-14 21:44:43 +02:00
committed by GitHub
parent 82af278ae5
commit a71b219c9a
20 changed files with 1606 additions and 79 deletions
@@ -22,13 +22,13 @@ module ImportScripts::PhpBB3
if version.start_with?('3.0')
require_relative 'database_3_0'
Database_3_0.new(@database_client, @database_settings)
elsif version.start_with?('3.1')
elsif version.start_with?('3.1') || version.start_with?('3.2')
require_relative 'database_3_1'
Database_3_1.new(@database_client, @database_settings)
else
raise UnsupportedVersionError, <<~MSG
Unsupported version (#{version}) of phpBB detected.
Currently only 3.0.x and 3.1.x are supported by this importer.
Currently only version 3.0, 3.1 and 3.2 are supported by this importer.
MSG
end
end
@@ -53,6 +53,20 @@ module ImportScripts::PhpBB3
SQL
end
def fetch_groups
query(<<-SQL)
SELECT g.group_id, g.group_type, g.group_name, g.group_desc
FROM #{@table_prefix}groups g
SQL
end
def fetch_group_users
query(<<-SQL)
SELECT ug.group_id, ug.user_id, ug.group_leader
FROM #{@table_prefix}user_group ug
SQL
end
def fetch_categories
query(<<-SQL)
SELECT f.forum_id, f.parent_id, f.forum_name, f.forum_desc, x.first_post_time
@@ -213,12 +227,20 @@ module ImportScripts::PhpBB3
SELECT b.user_id, t.topic_first_post_id
FROM #{@table_prefix}bookmarks b
JOIN #{@table_prefix}topics t ON (b.topic_id = t.topic_id)
WHERE b.user_id > #{last_user_id} AND b.topic_id > #{last_topic_id}
WHERE b.user_id > #{last_user_id}
ORDER BY b.user_id, b.topic_id
LIMIT #{@batch_size}
SQL
end
def get_smiley(smiley_code)
query(<<-SQL).first
SELECT emotion, smiley_url
FROM #{@table_prefix}smilies
WHERE code = '#{smiley_code}'
SQL
end
def get_config_values
query(<<-SQL).first
SELECT