2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-07 09:43:09 +08:00
|
|
|
module SiteSettings
|
|
|
|
end
|
|
|
|
|
|
|
|
module SiteSettings::DeprecatedSettings
|
2018-11-20 11:59:38 +08:00
|
|
|
SETTINGS = [
|
2022-02-07 11:26:06 +08:00
|
|
|
# [<old setting>, <new_setting>, <override>, <version to drop>]
|
2022-01-26 15:24:11 +08:00
|
|
|
["search_tokenize_chinese_japanese_korean", "search_tokenize_chinese", true, "2.9"],
|
2022-06-20 11:49:33 +08:00
|
|
|
["default_categories_regular", "default_categories_normal", true, "3.0"],
|
2022-09-26 11:58:40 +08:00
|
|
|
["min_trust_to_send_messages", "personal_message_enabled_groups", false, "3.0"],
|
|
|
|
["enable_personal_messages", "personal_message_enabled_groups", false, "3.0"],
|
2022-09-29 07:24:33 +08:00
|
|
|
["secure_media", "secure_uploads", true, "3.0"],
|
|
|
|
[
|
|
|
|
"secure_media_allow_embed_images_in_emails",
|
|
|
|
"secure_uploads_allow_embed_images_in_emails",
|
|
|
|
true,
|
|
|
|
"3.0",
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"secure_media_max_email_embed_image_size_kb",
|
|
|
|
"secure_uploads_max_email_embed_image_size_kb",
|
|
|
|
true,
|
|
|
|
"3.0",
|
2023-01-09 20:10:19 +08:00
|
|
|
],
|
2017-08-07 09:43:09 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
def setup_deprecated_methods
|
2018-11-20 11:59:38 +08:00
|
|
|
SETTINGS.each do |old_setting, new_setting, override, version|
|
2018-11-14 18:07:04 +08:00
|
|
|
unless override
|
|
|
|
SiteSetting.singleton_class.public_send(
|
|
|
|
:alias_method,
|
|
|
|
:"_#{old_setting}",
|
|
|
|
:"#{old_setting}",
|
|
|
|
)
|
|
|
|
end
|
2018-11-14 17:32:32 +08:00
|
|
|
|
2018-11-14 16:09:26 +08:00
|
|
|
define_singleton_method old_setting do |warn: true|
|
|
|
|
if warn
|
2021-12-14 00:36:19 +08:00
|
|
|
Discourse.deprecate(
|
|
|
|
"`SiteSetting.#{old_setting}` has been deprecated. Please use `SiteSetting.#{new_setting}` instead.",
|
|
|
|
drop_from: version,
|
2018-11-14 16:09:26 +08:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-11-14 17:32:32 +08:00
|
|
|
self.public_send(override ? new_setting : "_#{old_setting}")
|
2017-08-07 09:43:09 +08:00
|
|
|
end
|
|
|
|
|
2018-11-14 18:07:04 +08:00
|
|
|
unless override
|
|
|
|
SiteSetting.singleton_class.public_send(
|
|
|
|
:alias_method,
|
|
|
|
:"_#{old_setting}?",
|
|
|
|
:"#{old_setting}?",
|
|
|
|
)
|
|
|
|
end
|
2018-11-14 17:32:32 +08:00
|
|
|
|
2018-11-14 16:09:26 +08:00
|
|
|
define_singleton_method "#{old_setting}?" do |warn: true|
|
|
|
|
if warn
|
2021-12-14 00:36:19 +08:00
|
|
|
Discourse.deprecate(
|
|
|
|
"`SiteSetting.#{old_setting}?` has been deprecated. Please use `SiteSetting.#{new_setting}?` instead.",
|
|
|
|
drop_from: version,
|
2018-11-14 16:09:26 +08:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-11-14 17:32:32 +08:00
|
|
|
self.public_send("#{override ? new_setting : "_" + old_setting}?")
|
2017-08-07 09:43:09 +08:00
|
|
|
end
|
|
|
|
|
2018-11-14 18:07:04 +08:00
|
|
|
unless override
|
|
|
|
SiteSetting.singleton_class.public_send(
|
|
|
|
:alias_method,
|
|
|
|
:"_#{old_setting}=",
|
|
|
|
:"#{old_setting}=",
|
|
|
|
)
|
|
|
|
end
|
2018-11-14 17:32:32 +08:00
|
|
|
|
2018-11-14 16:09:26 +08:00
|
|
|
define_singleton_method "#{old_setting}=" do |val, warn: true|
|
|
|
|
if warn
|
2021-12-14 00:36:19 +08:00
|
|
|
Discourse.deprecate(
|
|
|
|
"`SiteSetting.#{old_setting}=` has been deprecated. Please use `SiteSetting.#{new_setting}=` instead.",
|
|
|
|
drop_from: version,
|
2018-11-14 16:09:26 +08:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-11-14 17:32:32 +08:00
|
|
|
self.public_send("#{override ? new_setting : "_" + old_setting}=", val)
|
2017-08-07 09:43:09 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|