0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-11 02:59:07 +08:00
discourse/app/controllers/admin/config/welcome_banner_controller.rb
Gabriel Grubba f9f1540323
FIX: Report effective welcome banner state for themes without overrides (#42451)
Previously, the `themes-with-setting` endpoint reported themes with no
`ThemeSiteSetting` override as disabled, even though a missing override
means the theme inherits the `enable_welcome_banner` default (true), so
saving unrelated fields on the admin welcome-banner form silently
persisted `false` and hid the banner for those themes.

This change falls back to `SiteSetting.defaults[:enable_welcome_banner]`
only when no override row exists — while still reporting explicit
`false` overrides correctly — matching how
`ThemeSiteSetting.generate_theme_map` and `ThemeSiteSettingResolver`
resolve effective values.

## Source

- Patch Triage: https://patch.discourse.org/patch-triage/1666

Co-authored-by: discourse-patch-triage
<272280883+discourse-patch-triage[bot]@users.noreply.github.com>
2026-08-10 11:48:18 -03:00

23 lines
704 B
Ruby
Vendored

# frozen_string_literal: true
class Admin::Config::WelcomeBannerController < Admin::AdminController
def index
end
def themes_with_setting
themes =
Theme
.not_components
.where("themes.id = ? OR themes.user_selectable = ?", SiteSetting.default_theme_id, true)
.includes(:theme_site_settings)
themes_data =
themes.map do |theme|
setting = theme.theme_site_settings.find { |s| s.name == "enable_welcome_banner" }
value = setting ? setting.setting_rb_value : SiteSetting.defaults[:enable_welcome_banner]
{ id: theme.id, name: theme.name, enable_welcome_banner: value }
end
render json: { themes: themes_data }
end
end