mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:41:17 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user