discourse/app/jobs/scheduled/clean_up_deprecated_url_site_settings.rb
Sam Saffron 9be70a22cd DEV: introduce new API to look up dynamic site setting
This removes all uses of both `send` and `public_send` from consumers of
SiteSetting and instead introduces a `get` helper for dynamic lookup

This leads to much cleaner and safer code long term as we are always explicit
to test that a site setting is really there before sending an arbitrary
string to the class

It also removes a couple of risky stubs from the auth provider test
2019-05-07 11:00:30 +10:00

15 lines
429 B
Ruby

module Jobs
class CleanUpDeprecatedUrlSiteSettings < Jobs::Scheduled
every 1.day
def execute(args)
Jobs::MigrateUrlSiteSettings::SETTINGS.each do |old_setting, new_setting|
if SiteSetting.where("name = ? AND value IS NOT NULL", new_setting).exists?
SiteSetting.set(old_setting, nil, warn: false)
SiteSetting.find_by(name: old_setting).destroy!
end
end
end
end
end