mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
DEV: couple bug fixes in getsatisfaction importer
- Ensure we don't modify a frozen string - Ensure we have a slug before trying to create a permalink
This commit is contained in:
parent
7f2b5a446a
commit
7a6d772ad2
1 changed files with 5 additions and 4 deletions
|
@ -351,7 +351,7 @@ class ImportScripts::GetSatisfaction < ImportScripts::Base
|
||||||
raw.gsub!(" ", "\n\n")
|
raw.gsub!(" ", "\n\n")
|
||||||
|
|
||||||
hoisted.each do |hoist, code|
|
hoisted.each do |hoist, code|
|
||||||
raw.gsub!(hoist, "\n```\n" << code << "\n```\n")
|
raw.gsub!(hoist, "\n```\n#{code}\n```\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
raw = CGI.unescapeHTML(raw)
|
raw = CGI.unescapeHTML(raw)
|
||||||
|
@ -365,9 +365,10 @@ class ImportScripts::GetSatisfaction < ImportScripts::Base
|
||||||
Topic.listable_topics.find_each do |topic|
|
Topic.listable_topics.find_each do |topic|
|
||||||
tcf = topic.first_post.custom_fields
|
tcf = topic.first_post.custom_fields
|
||||||
if tcf && tcf["import_id"]
|
if tcf && tcf["import_id"]
|
||||||
slug = @topic_slug[tcf["import_id"]]
|
if slug = @topic_slug[tcf["import_id"]]
|
||||||
slug = slug.gsub(OLD_DOMAIN, "")
|
slug.gsub!(OLD_DOMAIN, "")
|
||||||
Permalink.create(url: slug, topic_id: topic.id)
|
Permalink.find_or_create_by(url: slug, topic_id: topic.id) if slug.present?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue