Thanks for all the excellent work here. I have just imported my phpBB forum to discourse.
I am seeing an issue with attachments.
When the jpg is added to the post as an attachment and inserted using the [attachment ] tag, the result is simply the tag:
[attachment=0]IMG_2911a.JPG[/attachment]
Has anyone encountered this?
Does the attachment get pulled over to discourse anywhere, so I could fix this manually?
The importer detects the already imported topics/posts and does nothing. I’m not sure yet, but I think the import function I’m planning to implement wont be able to update already imported posts and add those attachments…
Not automatically. But you can do this in the Rails console, if the converter script has set some custom field on imported posts. This should be the case for most current importer scripts.
system_user = Discourse.system_user
PostCustomField.joins(:post).includes(:post).where(name: 'import_id').map {|pcf| pcf.post.topic_id }.sort.uniq.each do |topic_id|
PostDestroyer.new(system_user, Topic.find(topic_id).ordered_posts.first).destroy
end
Looking at the code, trying to understand the ruby…
I see that there is a method “create_upload” in base but that does not seem to be called anywhere in base or in phpBB script yet some posts have uploads that were pulled across. What am I missing?
Note, when the script rendered the links to these uploads, the IP address was used and not my host name. Is this a script issue or configuration on my part?
Have you edited the variables at the top of the script?
ORIGINAL_SITE_PREFIX = "oldsite.example.com/forums" # without http(s)://
NEW_SITE_PREFIX = "http://discourse.example.com" # with http:// or https://
Also, as discussed earlier, that script isn’t handling phpbb uploads at all. I’m working on it now, but with a site that has already been imported. I’ll try to backport my work to that script.
@gerhard said he was going to work on it “in the next few weeks”, but I can’t wait. I’ll try to share what I come up with.
Ouch. Discourse doesn’t do recursive destroys. Which means that your database now contains a bunch of orphaned posts.
[TopicAllowedUser, TopicAllowedGroup, TopicUser, TopicCustomField].each do |model|
model.includes(:topic).select {|p| p.topic.nil? }.each(&:destroy)
end
system_user = Discourse.system_user
Post.includes(:topic).select {|p| p.topic.nil? }.each do |post|
PostDestroyer.new(system_user, post).destroy
end
That should at least catch the most obnoxious garbage, but the remaining users may have wrong topic counters. At least for a while, until sidekiq updates the stats.
Drat. If we assume that at least the topics table has been cleaned out, you could try to just flush the orphaned post custom fields, and live with a few orphan posts remaining in the database. Without those, the importer should not recognize anything as already imported.