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"],
|
2023-10-25 09:45:10 +08:00
|
|
|
["anonymous_posting_min_trust_level", "anonymous_posting_allowed_groups", false, "3.3"],
|
2023-11-07 12:03:25 +08:00
|
|
|
["shared_drafts_min_trust_level", "shared_drafts_allowed_groups", false, "3.3"],
|
2023-11-09 10:07:01 +08:00
|
|
|
["min_trust_level_for_here_mention", "here_mention_allowed_groups", false, "3.3"],
|
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
|