aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorBenoit Tigeot <benoit@hopsandfork.com>2019-06-21 15:12:09 +0200
committerBenoit Tigeot <benoit@hopsandfork.com>2019-06-22 09:11:16 +0200
commit968fcd6b80ab884430f40e27e0e4be2ba0cc3ce9 (patch)
tree1d24681613e0e05aa34df274142f3ddd7e29fef7 /activesupport
parenta2a515d9de4ef0ddf4d78b05fcb0b838d2e1b5e3 (diff)
downloadrails-968fcd6b80ab884430f40e27e0e4be2ba0cc3ce9.tar.gz
rails-968fcd6b80ab884430f40e27e0e4be2ba0cc3ce9.tar.bz2
rails-968fcd6b80ab884430f40e27e0e4be2ba0cc3ce9.zip
Rely on Kernel require instead of self require
With this code (exctracted from derailed_benchmarks): ```ruby require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "rails", "~> 6.0.0.rc1", require: false end FILES = [ "rails/engine/configuration", "rails/source_annotation_extractor", "active_support/deprecation" ] module Kernel alias :original_require :require def require(file) Kernel.require(file) end class << self alias :original_require :require end end Kernel.define_singleton_method(:require) do |file| original_require(file) end FILES.each do |file| puts "requiring file: #{file}" require file end ``` It fails with Rails 6 and the change introduced by 32065 ``` requiring file: rails/engine/configuration requiring file: rails/source_annotation_extractor Traceback (most recent call last): 11: from repro_derailed.rb:33:in `<main>' 10: from repro_derailed.rb:33:in `each' 9: from repro_derailed.rb:35:in `block in <main>' 8: from repro_derailed.rb:21:in `require' 7: from repro_derailed.rb:30:in `block in <main>' 6: from repro_derailed.rb:30:in `require' 5: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/railties-6.0.0.rc1/lib/rails/source_annotation_extractor.rb:8:in `<top (required)>' 4: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new' 3: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new' 2: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:125:in `initialize' 1: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:23:in `method_missing' /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:148:in `warn': private method `warn' called for nil:NilClass (NoMethodError) ``` Related: - https://github.com/schneems/derailed_benchmarks/pull/130 - https://github.com/rails/rails/pull/32065
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/deprecation/proxy_wrappers.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/deprecation/proxy_wrappers.rb b/activesupport/lib/active_support/deprecation/proxy_wrappers.rb
index 56f1e23136..fab6c1cd73 100644
--- a/activesupport/lib/active_support/deprecation/proxy_wrappers.rb
+++ b/activesupport/lib/active_support/deprecation/proxy_wrappers.rb
@@ -122,7 +122,7 @@ module ActiveSupport
# ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
class DeprecatedConstantProxy < DeprecationProxy
def initialize(old_const, new_const, deprecator = ActiveSupport::Deprecation.instance, message: "#{old_const} is deprecated! Use #{new_const} instead.")
- require "active_support/inflector/methods"
+ Kernel.require "active_support/inflector/methods"
@old_const = old_const
@new_const = new_const