A phpbb3 import issue was reported by pfaffman where the admin user’s posts are not showing up on the /posted page despite having thousands of posts listed on the user summary page. The issue is due to the posted field in TopicUser being set to false for imported topics.
pfaffman found that manually setting posted to true resolves the issue, but is unsure if updating all users is the best solution. cocococosti identified the cause as an issue with the ensure_consistency rake task, which generates a “duplicate key” error when trying to update existing TopicUser records. A fix has been proposed in this PR.
I did a phpbb3 import for a site. The admin user has thousands of posts, and that’s listed on the user summary page, and in https://estude.profcaju.com/u/USER/activity but when that user visits /posted they get only topics since the import.
When I look at I look at an imported topic that was created by the user, and pull up Topicuser for that topic/user, posted is set to false. I’ve run all of the ensure_consistency things I can find (TopicUser, Topic, User).
If I set posted to true in a TopicUser, it will show up in /posted.
Should I do something like TopicUser.where(user_id: 1).update_all(posted: true)? Should I do that for all users?
Seems like an issue with the ensure_consistency rake task. I just checked on a migration I’m working on now (haven’t run the ensure_consistency task yet) and the TopicUser records were already created with posted: false (the default). When the rake task reaches this point it generates a “duplicate key” error and the records are not created because of the ON CONFLICT DO NOTHING
def insert_topic_users
log "Inserting topic users..."
DB.exec <<-SQL
INSERT INTO topic_users (user_id, topic_id, posted, last_read_post_number, first_visited_at, last_visited_at, total_msecs_viewed)
SELECT user_id, topic_id, 't' , MAX(post_number), MIN(created_at), MAX(created_at), COUNT(id) * #{MS_SPEND_CREATING_POST}
FROM posts
WHERE user_id > 0
GROUP BY user_id, topic_id
ON CONFLICT DO NOTHING
SQL
end