Replaces removed ActiveSupport::Deprecation.warn with custom deprecators (#41141, #36320).

Patch by Takashi Kato (user:tohosaku).


git-svn-id: https://svn.redmine.org/redmine/trunk@22961 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu
2024-08-20 05:58:38 +00:00
parent fb37d2e4fa
commit 9d50075279
4 changed files with 8 additions and 6 deletions

View File

@@ -1869,7 +1869,7 @@ module ApplicationHelper
def render_if_exist(options = {}, locals = {}, &block) def render_if_exist(options = {}, locals = {}, &block)
# Remove test_render_if_exist_should_be_render_partial and test_render_if_exist_should_be_render_nil # Remove test_render_if_exist_should_be_render_partial and test_render_if_exist_should_be_render_nil
# along with this method in Redmine 7.0 # along with this method in Redmine 7.0
ActiveSupport::Deprecation.warn 'ApplicationHelper#render_if_exist is deprecated and will be removed in Redmine 7.0.' Rails.application.deprecators[:redmine].warn 'ApplicationHelper#render_if_exist is deprecated and will be removed in Redmine 7.0.'
if options[:partial] if options[:partial]
if lookup_context.exists?(options[:partial], lookup_context.prefixes, true) if lookup_context.exists?(options[:partial], lookup_context.prefixes, true)

View File

@@ -40,3 +40,5 @@ Rails.application.config.to_prepare do
Rails.application.config.assets.redmine_extension_paths << paths if paths.present? Rails.application.config.assets.redmine_extension_paths << paths if paths.present?
end end
end end
Rails.application.deprecators[:redmine] = ActiveSupport::Deprecation.new('7.0', 'Redmine')

View File

@@ -61,7 +61,7 @@ module Redmine
elsif scope.respond_to?(:call) elsif scope.respond_to?(:call)
scope = scope.call scope = scope.call
else else
ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :scope option is deprecated. Please pass a scope on the #{self.name} as a proc." Rails.application.deprecators[:redmine].warn "acts_as_activity_provider with implicit :scope option is deprecated. Please pass a scope on the #{self.name} as a proc."
end end
scope = scope.where("#{provider_options[:timestamp]} >= ?", from) if from scope = scope.where("#{provider_options[:timestamp]} >= ?", from) if from
@@ -82,7 +82,7 @@ module Redmine
elsif respond_to?(:visible) elsif respond_to?(:visible)
scope = scope.visible(user, options) scope = scope.visible(user, options)
else else
ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option." Rails.application.deprecators[:redmine].warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option."
scope = scope.where(Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options)) scope = scope.where(Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options))
end end

View File

@@ -25,7 +25,7 @@ module Redmine
def initialize(*args) def initialize(*args)
if args.first.is_a?(ActionController::Base) if args.first.is_a?(ActionController::Base)
args.shift args.shift
ActiveSupport::Deprecation.warn "Paginator no longer takes a controller instance as the first argument. Remove it from #new arguments." Rails.application.deprecators[:redmine].warn "Paginator no longer takes a controller instance as the first argument. Remove it from #new arguments."
end end
item_count, per_page, page, page_param = *args item_count, per_page, page, page_param = *args
@@ -95,12 +95,12 @@ module Redmine
end end
def items_per_page def items_per_page
ActiveSupport::Deprecation.warn "Paginator#items_per_page will be removed. Use #per_page instead." Rails.application.deprecators[:redmine].warn "Paginator#items_per_page will be removed. Use #per_page instead."
per_page per_page
end end
def current def current
ActiveSupport::Deprecation.warn "Paginator#current will be removed. Use .offset instead of .current.offset." Rails.application.deprecators[:redmine].warn "Paginator#current will be removed. Use .offset instead of .current.offset."
self self
end end
end end