mirror of
https://github.com/discourse/discourse.git
synced 2025-03-23 19:55:41 +08:00
FIX: Handle BBCode in migrate_to_s3
task as well.
This commit is contained in:
parent
eec7822d7c
commit
19c3c25db1
@ -56,8 +56,6 @@ class DbHelper
|
||||
"#{column} IS NOT NULL AND #{column} #{match} :pattern"
|
||||
end.join(" OR ")
|
||||
|
||||
puts pattern, replacement, flags, match
|
||||
|
||||
DB.exec(<<~SQL, pattern: pattern, replacement: replacement, flags: flags, match: match)
|
||||
UPDATE #{table}
|
||||
SET #{set}
|
||||
|
@ -367,6 +367,13 @@ def migrate_to_s3
|
||||
|
||||
DbHelper.regexp_replace(from, to)
|
||||
|
||||
# BBCode images
|
||||
from = "\\[img\\]/uploads/#{db}/original/(\\dX/(?:[a-f0-9]/)*[a-f0-9]{40}[a-z0-9\\.]*)\\[/img\\]"
|
||||
to = "[img]#{SiteSetting.Upload.s3_base_url}/#{prefix}\\1[/img]"
|
||||
|
||||
DbHelper.regexp_replace(from, to)
|
||||
|
||||
# Legacy inline image format
|
||||
Post.where("raw LIKE '%%'").each do |post|
|
||||
regexp = /!\[\](\/uploads\/#{db}\/original\/(\dX\/(?:[a-f0-9]\/)*[a-f0-9]{40}[a-z0-9\.]*))/
|
||||
|
||||
|
@ -41,4 +41,14 @@ RSpec.describe DbHelper do
|
||||
expect(post.reload.cooked).to eq('test')
|
||||
end
|
||||
end
|
||||
|
||||
describe ".regexp_replace" do
|
||||
it "should remap columns correctly" do
|
||||
post = Fabricate(:post, raw: "this is a [img]test[/img] post")
|
||||
|
||||
DbHelper.regexp_replace("\\[img\\]test\\[/img\\]", "[img]something[/img]")
|
||||
|
||||
expect(post.reload.raw).to include("[img]something[/img]")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user