diff --git a/app/jobs/scheduled/clean_up_uploads.rb b/app/jobs/scheduled/clean_up_uploads.rb index 88d29c0c8a5..21f67f81f30 100644 --- a/app/jobs/scheduled/clean_up_uploads.rb +++ b/app/jobs/scheduled/clean_up_uploads.rb @@ -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) diff --git a/db/fixtures/001_categories.rb b/db/fixtures/001_categories.rb index c6880b53385..5e47dbcf2c1 100644 --- a/db/fixtures/001_categories.rb +++ b/db/fixtures/001_categories.rb @@ -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) diff --git a/db/migrate/20161025083648_fix_category_logo_and_background_urls.rb b/db/migrate/20161025083648_fix_category_logo_and_background_urls.rb new file mode 100644 index 00000000000..1f0f5b1a98b --- /dev/null +++ b/db/migrate/20161025083648_fix_category_logo_and_background_urls.rb @@ -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