DEV: allow for method deprecation using Discourse.deprecate

New method deprecator will ensure one log message an hour happens
for all deprecated method calls per call site

Also removes unused monkey patches to ActiveRecord::Base
This commit is contained in:
Sam
2018-06-20 17:50:11 +10:00
parent cb824a6b33
commit 44091f20c6
3 changed files with 57 additions and 14 deletions

View File

@ -527,6 +527,23 @@ module Discourse
end
end
def self.deprecate(warning)
location = caller_locations[1]
warning = "Deprecation Notice: #{warning}\nAt: #{location.label} #{location.path}:#{location.lineno}"
if Rails.env == "development"
STDERR.puts(warning)
end
digest = Digest::MD5.hexdigest(warning)
redis_key = "deprecate-notice-#{digest}"
if !$redis.without_namespace.get(redis_key)
Rails.logger.warn(warning)
$redis.without_namespace.setex(redis_key, 3600, "x")
end
warning
end
SIDEKIQ_NAMESPACE ||= 'sidekiq'.freeze
def self.sidekiq_redis_config