Skip to content

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.rb
index c9dab503168..8fd6887c3ef 100644
--- a/app/models/remote_theme.rb
+++ b/app/models/remote_theme.rb
@@ -269,19 +269,15 @@ class RemoteTheme < ActiveRecord::Base
end
end
- # 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.message
end
# Update all theme attributes if this is just a placeholder
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 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: list
list_type: file_types
- theme_download_screenshots:
- default: false
- hidden: true
authorized_extensions:
client: true
default: "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.rb
new file mode 100644
index 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
+end
diff --git a/spec/models/remote_theme_spec.rb b/spec/models/remote_theme_spec.rb
index bf351aab15b..5cc355b4102 100644
--- a/spec/models/remote_theme_spec.rb
+++ b/spec/models/remote_theme_spec.rb
@@ -1,6 +1,17 @@
# frozen_string_literal: true
RSpec.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" do
def about_json(
love_color: "FAFAFA",
@@ -195,7 +206,7 @@ RSpec.describe RemoteTheme do
expect(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 do
end
describe "screenshots" do
- before { SiteSetting.theme_download_screenshots = true }
-
it "fails if any of the provided screenshots is not an accepted file type" do
stub_const(ThemeScreenshotsHandler, "THEME_SCREENSHOT_ALLOWED_FILE_TYPES", [".bmp"]) do
expect { RemoteTheme.import_theme(initial_repo_url) }.to raise_error(
@@ -439,15 +448,6 @@ RSpec.describe RemoteTheme do
end
it "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")