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 current version of the importer canāt import attachments. Iām going to implement this in the next few weeks unless someone else does it earlierā¦
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.