A platform for community discussion. Free, open, simple.
DEV: remove theme_download_screenshots site setting (#32612)
Krzysztof Kotlarekdcc0eff0c703
diff --git a/app/models/remote_theme.rb b/app/models/remote_theme.rbindex c9dab503168..8fd6887c3ef 100644--- a/app/models/remote_theme.rb+++ b/app/models/remote_theme.rb@@ -269,19 +269,15 @@ class RemoteTheme < ActiveRecord::Baseendend- # TODO (martin): Until we are ready to roll this out more- # widely, let's avoid doing this work for most sites.- if SiteSetting.theme_download_screenshots- begin- updated_fields.concat(- ThemeScreenshotsHandler.new(theme).parse_screenshots_as_theme_fields!(- theme_info["screenshots"],- importer,- ),- )- rescue ThemeScreenshotsHandler::ThemeScreenshotError => err- raise ImportError, err.message- end+ begin+ updated_fields.concat(+ ThemeScreenshotsHandler.new(theme).parse_screenshots_as_theme_fields!(+ theme_info["screenshots"],+ importer,+ ),+ )+ rescue ThemeScreenshotsHandler::ThemeScreenshotError => err+ raise ImportError, err.messageend# Update all theme attributes if this is just a placeholderdiff --git a/config/site_settings.yml b/config/site_settings.ymlindex 583db59fe3a..720864b3177 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -1920,9 +1920,6 @@ files:default: "wasm|jpg|jpeg|png|woff|woff2|svg|eot|ttf|otf|gif|webp|avif|js"type: listlist_type: file_types- theme_download_screenshots:- default: false- hidden: trueauthorized_extensions:client: truedefault: "jpg|jpeg|png|gif|heic|heif|webp|avif"diff --git a/db/migrate/20250507013646_remove_theme_download_screenshots_site_settings.rb b/db/migrate/20250507013646_remove_theme_download_screenshots_site_settings.rbnew file mode 100644index 00000000000..67682e3a60c--- /dev/null+++ b/db/migrate/20250507013646_remove_theme_download_screenshots_site_settings.rb@@ -0,0 +1,10 @@+# frozen_string_literal: true+class RemoveThemeDownloadScreenshotsSiteSettings < ActiveRecord::Migration[7.2]+ def up+ execute "DELETE FROM site_settings WHERE name = 'theme_download_screenshots'"+ end++ def down+ raise ActiveRecord::IrreversibleMigration+ end+enddiff --git a/spec/models/remote_theme_spec.rb b/spec/models/remote_theme_spec.rbindex bf351aab15b..5cc355b4102 100644--- a/spec/models/remote_theme_spec.rb+++ b/spec/models/remote_theme_spec.rb@@ -1,6 +1,17 @@# frozen_string_literal: trueRSpec.describe RemoteTheme do+ before do+ FastImage+ .stubs(:size)+ .with { |arg| arg.match(%r{/screenshots/light\.jpeg}) }+ .returns([800, 600])+ FastImage+ .stubs(:size)+ .with { |arg| arg.match(%r{/screenshots/dark\.jpeg}) }+ .returns([1024, 768])+ end+describe "#import_theme" dodef about_json(love_color: "FAFAFA",@@ -195,7 +206,7 @@ RSpec.describe RemoteTheme doexpect(theme.theme_modifier_set.serialize_topic_excerpts).to eq(true)expect(theme.theme_modifier_set.custom_homepage).to eq(true)- expect(theme.theme_fields.length).to eq(12)+ expect(theme.theme_fields.length).to eq(14)mapped = Hash[*theme.theme_fields.map { |f| ["#{f.target_id}-#{f.name}", f.value] }.flatten]@@ -216,7 +227,7 @@ RSpec.describe RemoteTheme do"export default function migrate(settings) {\n return settings;\n}\n",)- expect(mapped.length).to eq(12)+ expect(mapped.length).to eq(14)expect(theme.settings.length).to eq(2)expect(theme.settings[:boolean_setting].value).to eq(true)@@ -390,8 +401,6 @@ RSpec.describe RemoteTheme doenddescribe "screenshots" do- before { SiteSetting.theme_download_screenshots = true }-it "fails if any of the provided screenshots is not an accepted file type" dostub_const(ThemeScreenshotsHandler, "THEME_SCREENSHOT_ALLOWED_FILE_TYPES", [".bmp"]) doexpect { RemoteTheme.import_theme(initial_repo_url) }.to raise_error(@@ -439,15 +448,6 @@ RSpec.describe RemoteTheme doendit "creates uploads and associated theme fields for all theme screenshots" do- FastImage- .stubs(:size)- .with { |arg| arg.match(%r{/screenshots/light\.jpeg}) }- .returns([800, 600])- FastImage- .stubs(:size)- .with { |arg| arg.match(%r{/screenshots/dark\.jpeg}) }- .returns([1024, 768])-theme = RemoteTheme.import_theme(initial_repo_url)screenshot_1 = theme.theme_fields.find_by(name: "screenshot_light")