XenForo 导入脚本导入了被封禁的用户以及软删除的主题和帖子

我今天使用了这个脚本,运行效果良好。唯一的问题是它导入了所有被禁止的用户以及 XenForo 中被软删除(隐藏)的帖子/主题。这导致在导入后,Discourse 中出现了数百条垃圾帖子/主题。

如果您有大量不希望导入的垃圾帖子/主题,那么建议对“xenforo.rb”脚本进行以下 SQL 修改:

  1. 添加以下 WHERE 子句,以确保仅导入活跃且未被禁止的用户。
       def import_users
        puts '', "creating users"

        total_count = mysql_query("SELECT count(*) count FROM #{TABLE_PREFIX}user;").first['count']

        batches(BATCH_SIZE) do |offset|
          results = mysql_query(
            "SELECT user_id id, username, email, custom_title title, register_date created_at,
                    last_activity last_visit_time, user_group_id, is_moderator, is_admin, is_staff
             FROM #{TABLE_PREFIX}user
             WHERE user_state = 'valid' AND is_banned = 0
             LIMIT #{BATCH_SIZE}
             OFFSET #{offset};")
  1. 修改以下 WHERE 子句,以确保仅导入可见的主题/帖子。
       def import_posts
        puts "", "creating topics and posts"

        total_count = mysql_query("SELECT count(*) count from #{TABLE_PREFIX}post").first["count"]

        posts_sql = "
            SELECT p.post_id id,
                   t.thread_id topic_id,
                   #{@prefix_as_category ? 't.prefix_id' : 't.node_id'} category_id,
                   t.title title,
                   t.first_post_id first_post_id,
                   p.user_id user_id,
                   p.message raw,
                   p.post_date created_at
            FROM #{TABLE_PREFIX}post p,
                 #{TABLE_PREFIX}thread t
            WHERE p.thread_id = t.thread_id AND p.message_state = 'visible' AND t.discussion_state = 'visible'
            ORDER BY p.post_date
            LIMIT #{BATCH_SIZE}" # needs OFFSET
5 个赞

好的,谢谢。我们能否将这些更改合并到我们的脚本中 @techAPJ

4 个赞

已完成,通过:

感谢 @msinger 的提示。:+1:

6 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.