Skip to content

Commit 48ce13f

Browse files
committed
Remove deprecated support to passing an array of strings to ActiveSupport::Deprecation#warn
1 parent 44a4f27 commit 48ce13f

File tree

4 files changed

+18
-28
lines changed

4 files changed

+18
-28
lines changed

activesupport/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Remove deprecated support to passing an array of strings to `ActiveSupport::Deprecation#warn`.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove deprecated support to setting `attr_internal_naming_format` with a `@` prefix.
26

37
*Rafael Mendonça França*

activesupport/lib/active_support/deprecation/reporting.rb

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ def deprecation_caller_message(callstack)
139139

140140
def extract_callstack(callstack)
141141
return [] if callstack.empty?
142-
return _extract_callstack(callstack) if callstack.first.is_a? String
143142

144143
offending_line = callstack.find { |frame|
145144
# Code generated with `eval` doesn't have an `absolute_path`, e.g. templates.
@@ -150,24 +149,6 @@ def extract_callstack(callstack)
150149
[offending_line.path, offending_line.lineno, offending_line.label]
151150
end
152151

153-
def _extract_callstack(callstack)
154-
ActiveSupport.deprecator.warn(<<~MESSAGE)
155-
Passing the result of `caller` to ActiveSupport::Deprecation#warn is deprecated and will be removed in Rails 8.0.
156-
157-
Please pass the result of `caller_locations` instead.
158-
MESSAGE
159-
160-
offending_line = callstack.find { |line| !ignored_callstack?(line) } || callstack.first
161-
162-
if offending_line
163-
if md = offending_line.match(/^(.+?):(\d+)(?::in `(.*?)')?/)
164-
md.captures
165-
else
166-
offending_line
167-
end
168-
end
169-
end
170-
171152
RAILS_GEM_ROOT = File.expand_path("../../../..", __dir__) + "/" # :nodoc:
172153
LIB_DIR = RbConfig::CONFIG["libdir"] # :nodoc:
173154

activesupport/test/deprecation_test.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ def setup
3939
end
4040
end
4141

42-
test "passing callstack as `caller` is deprecated" do
43-
assert_deprecated(/Passing the result of `caller` to ActiveSupport::Deprecation#warn/, ActiveSupport.deprecator) do
44-
assert_deprecated(@deprecator) do
45-
@deprecator.warn("Yo dawg!", caller)
46-
end
47-
end
48-
end
49-
5042
test "assert_deprecated requires a deprecator" do
5143
assert_raises(ArgumentError) do
5244
assert_deprecated do
@@ -196,11 +188,22 @@ def setup
196188
assert_match "call stack!", output
197189
end
198190

191+
class CallerLocation
192+
attr_reader :path, :lineno, :label
193+
alias_method :absolute_path, :path
194+
195+
def initialize(label, lineno)
196+
@path = __FILE__
197+
@lineno = lineno
198+
@label = label
199+
end
200+
end
201+
199202
test ":stderr behavior with #warn" do
200203
@deprecator.behavior = :stderr
201204

202205
output = capture(:stderr) do
203-
@deprecator.warn("Instance error!", ["instance call stack!"])
206+
@deprecator.warn("Instance error!", [CallerLocation.new("instance call stack!", __LINE__)])
204207
end
205208

206209
assert_match(/Instance error!/, output)

guides/source/8_0_release_notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ Please refer to the [Changelog][active-support] for detailed changes.
144144

145145
* Remove deprecated support to setting `attr_internal_naming_format` with a `@` prefix.
146146

147+
* Remove deprecated support to passing an array of strings to `ActiveSupport::Deprecation#warn`.
148+
147149
### Deprecations
148150

149151
### Notable changes

0 commit comments

Comments
 (0)