A platform for community discussion. Free, open, simple.
DEV: Fix syntax/formatting in xenforo import script (#19761)
David Taylord5491b13f5dd
diff --git a/script/import_scripts/xenforo.rb b/script/import_scripts/xenforo.rbindex 39ef48090de..38e45342c65 100755--- a/script/import_scripts/xenforo.rb+++ b/script/import_scripts/xenforo.rb@@ -89,6 +89,7 @@ class ImportScripts::XenForo < ImportScripts::Basepost_create_action: proc do |u|import_avatar(user['id'], u)end+ }endendend@@ -117,7 +118,7 @@ class ImportScripts::XenForo < ImportScripts::Baseposition: c['display_order'],post_create_action: proc do |category|url = "board/#{c['node_name']}"- Permalink.find_or_create_by(url: url, category_id: category.id)+ Permalink.find_or_create_by(url: url, category_id: category.id)end}end@@ -135,7 +136,7 @@ class ImportScripts::XenForo < ImportScripts::Baseparent_category_id: category_id_from_imported_category_id(c['parent_node_id']),post_create_action: proc do |category|url = "board/#{c['node_name']}"- Permalink.find_or_create_by(url: url, category_id: category.id)+ Permalink.find_or_create_by(url: url, category_id: category.id)end}end@@ -192,7 +193,7 @@ class ImportScripts::XenForo < ImportScripts::Basetotal_count = mysql_query("SELECT COUNT(*) AS count FROM #{TABLE_PREFIX}liked_content WHERE content_type = 'post'").first["count"]batches(BATCH_SIZE) do |offset|results = mysql_query(- "SELECT like_id, content_id, like_user_id, like_date+ "SELECT like_id, content_id, like_user_id, like_dateFROM #{TABLE_PREFIX}liked_contentWHERE content_type = 'post'ORDER BY like_id@@ -297,10 +298,10 @@ class ImportScripts::XenForo < ImportScripts::Basepost_count = mysql_query("SELECT COUNT(*) count FROM xf_conversation_message").first["count"]batches(BATCH_SIZE) do |offset|posts = mysql_query <<-SQL- SELECT c.conversation_id, c.recipients, c.title, m.message, m.user_id, m.message_date, m.message_id, IF(c.first_message_id != m.message_id, c.first_message_id, 0) as topic_id- FROM xf_conversation_master c- LEFT JOIN xf_conversation_message m ON m.conversation_id = c.conversation_id- ORDER BY c.conversation_id, m.message_id+ SELECT c.conversation_id, c.recipients, c.title, m.message, m.user_id, m.message_date, m.message_id, IF(c.first_message_id != m.message_id, c.first_message_id, 0) as topic_id+ FROM xf_conversation_master c+ LEFT JOIN xf_conversation_message m ON m.conversation_id = c.conversation_id+ ORDER BY c.conversation_id, m.message_idLIMIT #{BATCH_SIZE}OFFSET #{offset}SQL@@ -316,7 +317,7 @@ class ImportScripts::XenForo < ImportScripts::Baseid: message_id,user_id: user_id,raw: raw,- created_at: Time.zone.at(post["message_date"].to_i),+ created_at: Time.zone.at(post["message_date"].to_i),import_mode: true}unless post["topic_id"] > 0@@ -450,13 +451,13 @@ class ImportScripts::XenForo < ImportScripts::Basedef process_xf_attachments(xf_type, s, import_id)ids = Set.newids.merge(s.scan(get_xf_regexp(xf_type)).map { |x| x[0].to_i })-+# not all attachments have an [ATTACH=] tag so we need to get the other ID's from the xf_attachment tableif xf_type == :attachment && import_id > 0sql = "SELECT attachment_id FROM #{TABLE_PREFIX}attachment WHERE content_id=#{import_id} and content_type='post';"- ids.merge(mysql_query(sql).to_a.map { |v| v["attachment_id"].to_i})+ ids.merge(mysql_query(sql).to_a.map { |v| v["attachment_id"].to_i })end-+ids.each do |id|next unless idsql = get_xf_sql(xf_type, id).dup.squish!@@ -519,7 +520,7 @@ class ImportScripts::XenForo < ImportScripts::Basewhen :attachment<<-SQLSELECT a.attachment_id, a.data_id, d.filename, d.file_hash, d.user_id- FROM #{TABLE_PREFIX}attachment AS a+ FROM #{TABLE_PREFIX}attachment AS aINNER JOIN #{TABLE_PREFIX}attachment_data d ON a.data_id = d.data_idWHERE attachment_id = #{id}AND content_type = 'post'