mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
rescue error when remapping permalinks
This commit is contained in:
parent
b83c0747d9
commit
4623b46b0b
@ -451,22 +451,26 @@ task "import:remap_old_phpbb_permalinks" => :environment do
|
||||
i = 0
|
||||
# discussions.flightaware.com
|
||||
Post.where("raw LIKE ?", "%discussions.flightaware.com%").each do |p|
|
||||
new_raw = p.raw.dup
|
||||
# \((https?:\/\/discussions\.flightaware\.com\/\S*-t\d+.html)\)
|
||||
new_raw.gsub!(/\((https?:\/\/discussions\.flightaware\.com\/\S*-t\d+.html)\)/) do
|
||||
normalized_url = Permalink.normalize_url($1)
|
||||
permalink = Permalink.find_by_url(normalized_url) rescue nil
|
||||
if permalink && permalink.target_url
|
||||
"(#{permalink.target_url})"
|
||||
else
|
||||
"(#{$1})"
|
||||
begin
|
||||
new_raw = p.raw.dup
|
||||
# \((https?:\/\/discussions\.flightaware\.com\/\S*-t\d+.html)\)
|
||||
new_raw.gsub!(/\((https?:\/\/discussions\.flightaware\.com\/\S*-t\d+.html)\)/) do
|
||||
normalized_url = Permalink.normalize_url($1)
|
||||
permalink = Permalink.find_by_url(normalized_url) rescue nil
|
||||
if permalink && permalink.target_url
|
||||
"(#{permalink.target_url})"
|
||||
else
|
||||
"(#{$1})"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if new_raw != p.raw
|
||||
p.revise(Discourse.system_user, { raw: new_raw }, bypass_bump: true, skip_revision: true)
|
||||
putc "."
|
||||
i += 1
|
||||
if new_raw != p.raw
|
||||
p.revise(Discourse.system_user, { raw: new_raw }, bypass_bump: true, skip_revision: true)
|
||||
putc "."
|
||||
i += 1
|
||||
end
|
||||
rescue
|
||||
# skip
|
||||
end
|
||||
end
|
||||
i
|
||||
|
Loading…
Reference in New Issue
Block a user