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
|
i = 0
|
||||||
# discussions.flightaware.com
|
# discussions.flightaware.com
|
||||||
Post.where("raw LIKE ?", "%discussions.flightaware.com%").each do |p|
|
Post.where("raw LIKE ?", "%discussions.flightaware.com%").each do |p|
|
||||||
new_raw = p.raw.dup
|
begin
|
||||||
# \((https?:\/\/discussions\.flightaware\.com\/\S*-t\d+.html)\)
|
new_raw = p.raw.dup
|
||||||
new_raw.gsub!(/\((https?:\/\/discussions\.flightaware\.com\/\S*-t\d+.html)\)/) do
|
# \((https?:\/\/discussions\.flightaware\.com\/\S*-t\d+.html)\)
|
||||||
normalized_url = Permalink.normalize_url($1)
|
new_raw.gsub!(/\((https?:\/\/discussions\.flightaware\.com\/\S*-t\d+.html)\)/) do
|
||||||
permalink = Permalink.find_by_url(normalized_url) rescue nil
|
normalized_url = Permalink.normalize_url($1)
|
||||||
if permalink && permalink.target_url
|
permalink = Permalink.find_by_url(normalized_url) rescue nil
|
||||||
"(#{permalink.target_url})"
|
if permalink && permalink.target_url
|
||||||
else
|
"(#{permalink.target_url})"
|
||||||
"(#{$1})"
|
else
|
||||||
|
"(#{$1})"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if new_raw != p.raw
|
if new_raw != p.raw
|
||||||
p.revise(Discourse.system_user, { raw: new_raw }, bypass_bump: true, skip_revision: true)
|
p.revise(Discourse.system_user, { raw: new_raw }, bypass_bump: true, skip_revision: true)
|
||||||
putc "."
|
putc "."
|
||||||
i += 1
|
i += 1
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
# skip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
i
|
i
|
||||||
|
Loading…
Reference in New Issue
Block a user