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