FIX: category logo & background URLs should not use the CDN

This commit is contained in:
Régis Hanol 2016-10-25 10:43:57 +02:00
parent a6c62dbe73
commit 52b338db62
3 changed files with 22 additions and 6 deletions

View File

@ -12,8 +12,12 @@ module Jobs
ignore_urls |= Category.uniq.where("background_url IS NOT NULL AND background_url != ''").pluck(:background_url)
# Any URLs in site settings are fair game
ignore_urls |= [SiteSetting.logo_url, SiteSetting.logo_small_url, SiteSetting.favicon_url,
SiteSetting.apple_touch_icon_url]
ignore_urls |= [
SiteSetting.logo_url,
SiteSetting.logo_small_url,
SiteSetting.favicon_url,
SiteSetting.apple_touch_icon_url
]
ids = []
ids |= PostUpload.uniq.pluck(:upload_id)

View File

@ -1,5 +1,5 @@
# fix any bust caches post initial migration
ActiveRecord::Base.send(:subclasses).each{|m| m.reset_column_information}
ActiveRecord::Base.send(:subclasses).each { |m| m.reset_column_information }
SiteSetting.refresh!
uncat_id = SiteSetting.uncategorized_category_id
@ -10,9 +10,7 @@ if uncat_id == -1 || !Category.exists?(uncat_id)
result = Category.exec_sql "SELECT 1 FROM categories WHERE lower(name) = 'uncategorized'"
name = 'Uncategorized'
if result.count > 0
name << SecureRandom.hex
end
name << SecureRandom.hex if result.count > 0
result = Category.exec_sql "INSERT INTO categories
(name,color,slug,description,text_color, user_id, created_at, updated_at, position, name_lower)

View File

@ -0,0 +1,14 @@
class FixCategoryLogoAndBackgroundUrls < ActiveRecord::Migration
def up
return true if Discourse.asset_host.blank?
Category.exec_sql <<-SQL
UPDATE categories
SET logo_url = replace(logo_url, '#{Discourse.asset_host}', '')
, background_url = replace(background_url, '#{Discourse.asset_host}', '')
SQL
end
def down
end
end