FIX: remove site setting 'shadowed-by-global' option (#8061)

This commit is contained in:
Régis Hanol 2019-10-08 12:43:26 -04:00 committed by Robin Ward
parent b20b6c52e1
commit 349c1cd085
3 changed files with 7 additions and 44 deletions

View File

@ -11,9 +11,6 @@
# secret - Set to true if input type should be password and value needs to be scrubbed from logs (default false). # secret - Set to true if input type should be password and value needs to be scrubbed from logs (default false).
# enum - The setting has a fixed set of allowed values, and only one can be chosen. # enum - The setting has a fixed set of allowed values, and only one can be chosen.
# Set to the class name that defines the set. # Set to the class name that defines the set.
# shadowed_by_global - "Shadow" a site setting with a GlobalSetting. If the GlobalSetting
# exists it will be used instead of the setting and the setting will be hidden.
# Useful for things like API keys on multisite.
# locale_default - A hash which overrides according to `SiteSetting.default_locale`. # locale_default - A hash which overrides according to `SiteSetting.default_locale`.
# The key should be as the same as possible value of default_locale. # The key should be as the same as possible value of default_locale.
# #
@ -44,7 +41,6 @@ required:
notification_email: notification_email:
default: "noreply@unconfigured.discourse.org" default: "noreply@unconfigured.discourse.org"
type: email type: email
shadowed_by_global: true
site_contact_username: site_contact_username:
default: "" default: ""
type: username type: username
@ -848,10 +844,8 @@ posting:
default: 24 default: 24
auto_close_messages_post_count: auto_close_messages_post_count:
default: 500 default: 500
shadowed_by_global: true
auto_close_topics_post_count: auto_close_topics_post_count:
default: 10000 default: 10000
shadowed_by_global: true
code_formatting_style: code_formatting_style:
client: true client: true
type: enum type: enum
@ -882,7 +876,6 @@ posting:
hidden: true hidden: true
default: false default: false
client: true client: true
shadowed_by_global: true
old_post_notice_days: old_post_notice_days:
default: 14 default: 14
client: true client: true
@ -996,10 +989,8 @@ email:
default: false default: false
disallow_reply_by_email_after_days: disallow_reply_by_email_after_days:
default: 90 default: 90
shadowed_by_global: true
delete_email_logs_after_days: delete_email_logs_after_days:
default: 90 default: 90
shadowed_by_global: true
max_emails_per_day_per_user: 100 max_emails_per_day_per_user: 100
enable_staged_users: true enable_staged_users: true
maximum_staged_users_per_email: 10 maximum_staged_users_per_email: 10
@ -1123,46 +1114,36 @@ files:
clean_orphan_uploads_grace_period_hours: 48 clean_orphan_uploads_grace_period_hours: 48
purge_deleted_uploads_grace_period_days: purge_deleted_uploads_grace_period_days:
default: 30 default: 30
shadowed_by_global: true
prevent_anons_from_downloading_files: prevent_anons_from_downloading_files:
default: false default: false
client: true client: true
enable_s3_uploads: enable_s3_uploads:
default: false default: false
client: true client: true
shadowed_by_global: true
s3_use_iam_profile: s3_use_iam_profile:
default: false default: false
shadowed_by_global: true
s3_access_key_id: s3_access_key_id:
default: "" default: ""
secret: true secret: true
shadowed_by_global: true
s3_secret_access_key: s3_secret_access_key:
default: "" default: ""
secret: true secret: true
shadowed_by_global: true
s3_region: s3_region:
default: "us-east-1" default: "us-east-1"
enum: "S3RegionSiteSetting" enum: "S3RegionSiteSetting"
shadowed_by_global: true
s3_upload_bucket: s3_upload_bucket:
default: "" default: ""
regex: '^[a-z0-9\-\/_]+$' # can't use '.' when using HTTPS regex: '^[a-z0-9\-\/_]+$' # can't use '.' when using HTTPS
shadowed_by_global: true
s3_endpoint: s3_endpoint:
default: "" default: ""
regex: '^https?:\/\/.+[^\/]$' regex: '^https?:\/\/.+[^\/]$'
shadowed_by_global: true
s3_cdn_url: s3_cdn_url:
default: "" default: ""
regex: '^https?:\/\/.+[^\/]$' regex: '^https?:\/\/.+[^\/]$'
s3_configure_tombstone_policy: s3_configure_tombstone_policy:
default: true default: true
shadowed_by_global: true
enable_s3_inventory: enable_s3_inventory:
default: false default: false
shadowed_by_global: true
allow_profile_backgrounds: allow_profile_backgrounds:
client: true client: true
default: true default: true
@ -1185,13 +1166,11 @@ files:
external_system_avatars_enabled: external_system_avatars_enabled:
default: true default: true
client: true client: true
shadowed_by_global: true
validator: "ExternalSystemAvatarsValidator" validator: "ExternalSystemAvatarsValidator"
external_system_avatars_url: external_system_avatars_url:
default: "/letter_avatar_proxy/v4/letter/{first_letter}/{color}/{size}.png" default: "/letter_avatar_proxy/v4/letter/{first_letter}/{color}/{size}.png"
client: true client: true
regex: '^((https?:)?\/)?\/.+[^\/]' regex: '^((https?:)?\/)?\/.+[^\/]'
shadowed_by_global: true
restrict_letter_avatar_colors: restrict_letter_avatar_colors:
default: "" default: ""
type: list type: list
@ -1326,7 +1305,6 @@ security:
- "all" - "all"
force_https: force_https:
default: false default: false
shadowed_by_global: true
same_site_cookies: same_site_cookies:
default: Lax default: Lax
type: enum type: enum
@ -1364,7 +1342,6 @@ security:
default: "" default: ""
type: list type: list
list_type: compact list_type: compact
shadowed_by_global: true
whitelist_internal_hosts: whitelist_internal_hosts:
default: "" default: ""
type: list type: list
@ -1499,11 +1476,9 @@ rate_limits:
tl4_additional_likes_per_day_multiplier: 3 tl4_additional_likes_per_day_multiplier: 3
alert_admins_if_errors_per_minute: alert_admins_if_errors_per_minute:
client: true client: true
shadowed_by_global: true
default: 0 default: 0
alert_admins_if_errors_per_hour: alert_admins_if_errors_per_hour:
client: true client: true
shadowed_by_global: true
default: 0 default: 0
max_prints_per_hour_per_user: max_prints_per_hour_per_user:
default: 5 default: 5
@ -1640,35 +1615,28 @@ legal:
backups: backups:
enable_backups: enable_backups:
default: true default: true
shadowed_by_global: true
client: true client: true
readonly_mode_during_backup: readonly_mode_during_backup:
default: false default: false
allow_restore: allow_restore:
default: false default: false
shadowed_by_global: true
backup_location: backup_location:
default: "local" default: "local"
type: enum type: enum
enum: "BackupLocationSiteSetting" enum: "BackupLocationSiteSetting"
shadowed_by_global: true
client: true client: true
maximum_backups: maximum_backups:
client: true client: true
default: 5 default: 5
shadowed_by_global: true
automatic_backups_enabled: automatic_backups_enabled:
default: true default: true
shadowed_by_global: true
backup_frequency: backup_frequency:
min: 1 min: 1
max: 30 max: 30
default: 7 default: 7
shadowed_by_global: true
s3_backup_bucket: s3_backup_bucket:
default: "" default: ""
regex: '^[a-z0-9\-\/]+$' # can't use '.' when using HTTPS regex: '^[a-z0-9\-\/]+$' # can't use '.' when using HTTPS
shadowed_by_global: true
s3_disable_cleanup: s3_disable_cleanup:
default: false default: false
backup_time_of_day: backup_time_of_day:
@ -1679,13 +1647,10 @@ backups:
default: 1 default: 1
min: 1 min: 1
max: 9 max: 9
shadowed_by_global: true
include_thumbnails_in_backups: include_thumbnails_in_backups:
default: false default: false
shadowed_by_global: true
include_s3_uploads_in_backups: include_s3_uploads_in_backups:
default: false default: false
shadowed_by_global: true
hidden: true hidden: true
search: search:
@ -1748,7 +1713,6 @@ uncategorized:
version_checks: version_checks:
client: true client: true
default: true default: true
shadowed_by_global: true
new_version_emails: true new_version_emails: true
send_welcome_message: true send_welcome_message: true
@ -2079,7 +2043,6 @@ user_api:
allowed_user_api_push_urls: allowed_user_api_push_urls:
default: "" default: ""
type: list type: list
shadowed_by_global: true
allowed_user_api_auth_redirects: allowed_user_api_auth_redirects:
default: "https://api.discourse.org/api/auth_redirect|discourse://auth_redirect" default: "https://api.discourse.org/api/auth_redirect|discourse://auth_redirect"
type: list type: list

View File

@ -132,7 +132,7 @@ module SiteSettingExtension
hidden_settings << name hidden_settings << name
end end
if opts[:shadowed_by_global] && GlobalSetting.respond_to?(name) if GlobalSetting.respond_to?(name)
val = GlobalSetting.public_send(name) val = GlobalSetting.public_send(name)
unless val.nil? || (val == ''.freeze) unless val.nil? || (val == ''.freeze)

View File

@ -633,7 +633,7 @@ describe SiteSettingExtension do
end end
end end
describe "shadowed_by_global" do describe "global override" do
context "default_locale" do context "default_locale" do
it "supports adding a default locale via a global" do it "supports adding a default locale via a global" do
@ -645,7 +645,7 @@ describe SiteSettingExtension do
context "without global setting" do context "without global setting" do
before do before do
settings.setting(:trout_api_key, 'evil', shadowed_by_global: true) settings.setting(:trout_api_key, 'evil')
settings.refresh! settings.refresh!
end end
@ -667,7 +667,7 @@ describe SiteSettingExtension do
context "with blank global setting" do context "with blank global setting" do
before do before do
GlobalSetting.stubs(:nada).returns('') GlobalSetting.stubs(:nada).returns('')
settings.setting(:nada, 'nothing', shadowed_by_global: true) settings.setting(:nada, 'nothing')
settings.refresh! settings.refresh!
end end
@ -680,7 +680,7 @@ describe SiteSettingExtension do
context "with a false override" do context "with a false override" do
before do before do
GlobalSetting.stubs(:bool).returns(false) GlobalSetting.stubs(:bool).returns(false)
settings.setting(:bool, true, shadowed_by_global: true) settings.setting(:bool, true)
settings.refresh! settings.refresh!
end end
@ -700,7 +700,7 @@ describe SiteSettingExtension do
context "with global setting" do context "with global setting" do
before do before do
GlobalSetting.stubs(:trout_api_key).returns('purringcat') GlobalSetting.stubs(:trout_api_key).returns('purringcat')
settings.setting(:trout_api_key, 'evil', shadowed_by_global: true) settings.setting(:trout_api_key, 'evil')
settings.refresh! settings.refresh!
end end
@ -718,7 +718,7 @@ describe SiteSettingExtension do
['', nil].each_with_index do |setting, index| ['', nil].each_with_index do |setting, index|
GlobalSetting.stubs(:"trout_api_key_#{index}").returns(setting) GlobalSetting.stubs(:"trout_api_key_#{index}").returns(setting)
settings.setting(:"trout_api_key_#{index}", 'evil', shadowed_by_global: true) settings.setting(:"trout_api_key_#{index}", 'evil')
settings.refresh! settings.refresh!
expect(settings.hidden_settings.include?(:"trout_api_key_#{index}")).to eq(false) expect(settings.hidden_settings.include?(:"trout_api_key_#{index}")).to eq(false)
end end