Files
discourse/lib/site_settings
Ted Johansson 47286766da DEV: Support deprecating site settings in plugins (#36371)
In /app/models/site_setting.rb we call the method to setup deprecated setting methods in the class body. This iterates through the SiteSettings::DeprecatedSettings::SETTINGS array and defines the deprecation methods.

Because this is setup on class load, it becomes dependent on the order that files are loaded in. For example, if we try to add a deprecated setting from a plugin, using something like:

```rb
SiteSettings::DeprecatedSettings::SETTINGS << [
  "policy_restrict_to_staff_posts",
  "create_policy_allowed_groups",
  false,
  "3.6"
]
```

it will get appended to the array, but it won’t have the appropriate method generated, because #setup_deprecated_methods is evaluated before this plugin.rb file.

This change extracts the meat of #setup_deprecated_methods into #setup_deprecated_method, which can be called with a single setting.

We then use that in a new #deprecate_setting method on Plugin::Instance.
2025-12-03 13:30:35 +08:00
..