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