activesupport 6.0.2.1 → 6.0.3.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -0
- data/README.rdoc +1 -1
- data/lib/active_support/backtrace_cleaner.rb +0 -1
- data/lib/active_support/cache.rb +29 -28
- data/lib/active_support/cache/file_store.rb +7 -8
- data/lib/active_support/cache/mem_cache_store.rb +9 -19
- data/lib/active_support/cache/memory_store.rb +6 -7
- data/lib/active_support/cache/null_store.rb +3 -3
- data/lib/active_support/cache/redis_cache_store.rb +22 -17
- data/lib/active_support/cache/strategy/local_cache.rb +23 -23
- data/lib/active_support/callbacks.rb +0 -3
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +18 -0
- data/lib/active_support/concurrency/share_lock.rb +0 -1
- data/lib/active_support/core_ext/array/conversions.rb +5 -5
- data/lib/active_support/core_ext/date_and_time/zones.rb +0 -1
- data/lib/active_support/core_ext/date_time/conversions.rb +0 -1
- data/lib/active_support/core_ext/hash/conversions.rb +1 -1
- data/lib/active_support/core_ext/module/delegation.rb +8 -1
- data/lib/active_support/core_ext/module/introspection.rb +1 -0
- data/lib/active_support/core_ext/object/try.rb +2 -0
- data/lib/active_support/core_ext/range/each.rb +0 -1
- data/lib/active_support/core_ext/string/output_safety.rb +0 -1
- data/lib/active_support/dependencies.rb +0 -2
- data/lib/active_support/dependencies/zeitwerk_integration.rb +0 -1
- data/lib/active_support/deprecation/method_wrappers.rb +12 -6
- data/lib/active_support/deprecation/proxy_wrappers.rb +5 -1
- data/lib/active_support/descendants_tracker.rb +0 -1
- data/lib/active_support/duration.rb +13 -11
- data/lib/active_support/duration/iso8601_parser.rb +0 -1
- data/lib/active_support/duration/iso8601_serializer.rb +0 -1
- data/lib/active_support/encrypted_file.rb +1 -1
- data/lib/active_support/evented_file_update_checker.rb +0 -1
- data/lib/active_support/file_update_checker.rb +0 -1
- data/lib/active_support/gem_version.rb +2 -2
- data/lib/active_support/inflector/inflections.rb +0 -1
- data/lib/active_support/inflector/methods.rb +1 -2
- data/lib/active_support/json/decoding.rb +0 -1
- data/lib/active_support/lazy_load_hooks.rb +0 -1
- data/lib/active_support/locale/en.rb +4 -2
- data/lib/active_support/log_subscriber.rb +0 -1
- data/lib/active_support/logger.rb +1 -1
- data/lib/active_support/message_encryptor.rb +1 -1
- data/lib/active_support/message_verifier.rb +2 -2
- data/lib/active_support/messages/metadata.rb +3 -2
- data/lib/active_support/messages/rotator.rb +4 -4
- data/lib/active_support/multibyte/chars.rb +1 -2
- data/lib/active_support/multibyte/unicode.rb +0 -1
- data/lib/active_support/notifications/instrumenter.rb +0 -1
- data/lib/active_support/number_helper.rb +4 -0
- data/lib/active_support/number_helper/number_converter.rb +4 -5
- data/lib/active_support/number_helper/number_to_currency_converter.rb +7 -8
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_human_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_phone_converter.rb +0 -1
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +0 -1
- data/lib/active_support/option_merger.rb +21 -3
- data/lib/active_support/ordered_options.rb +4 -0
- data/lib/active_support/parameter_filter.rb +1 -2
- data/lib/active_support/string_inquirer.rb +0 -1
- data/lib/active_support/testing/parallelization.rb +8 -2
- data/lib/active_support/testing/stream.rb +0 -1
- data/lib/active_support/testing/time_helpers.rb +0 -2
- data/lib/active_support/xml_mini.rb +0 -1
- data/lib/active_support/xml_mini/jdom.rb +0 -1
- metadata +16 -10
@@ -74,32 +74,24 @@ module ActiveSupport
|
|
74
74
|
# Support raw values in the local cache strategy.
|
75
75
|
module LocalCacheWithRaw # :nodoc:
|
76
76
|
private
|
77
|
-
def
|
78
|
-
entry = super
|
79
|
-
if options[:raw] && local_cache && entry
|
80
|
-
entry = deserialize_entry(entry.value)
|
81
|
-
end
|
82
|
-
entry
|
83
|
-
end
|
84
|
-
|
85
|
-
def write_entry(key, entry, options)
|
77
|
+
def write_entry(key, entry, **options)
|
86
78
|
if options[:raw] && local_cache
|
87
79
|
raw_entry = Entry.new(serialize_entry(entry, raw: true))
|
88
80
|
raw_entry.expires_at = entry.expires_at
|
89
|
-
super(key, raw_entry, options)
|
81
|
+
super(key, raw_entry, **options)
|
90
82
|
else
|
91
83
|
super
|
92
84
|
end
|
93
85
|
end
|
94
86
|
|
95
|
-
def write_multi_entries(entries, options)
|
87
|
+
def write_multi_entries(entries, **options)
|
96
88
|
if options[:raw] && local_cache
|
97
89
|
raw_entries = entries.map do |key, entry|
|
98
90
|
raw_entry = Entry.new(serialize_entry(entry, raw: true))
|
99
91
|
raw_entry.expires_at = entry.expires_at
|
100
92
|
end.to_h
|
101
93
|
|
102
|
-
super(raw_entries, options)
|
94
|
+
super(raw_entries, **options)
|
103
95
|
else
|
104
96
|
super
|
105
97
|
end
|
@@ -346,13 +338,14 @@ module ActiveSupport
|
|
346
338
|
|
347
339
|
# Store provider interface:
|
348
340
|
# Read an entry from the cache.
|
349
|
-
def read_entry(key, options
|
341
|
+
def read_entry(key, **options)
|
350
342
|
failsafe :read_entry do
|
351
|
-
|
343
|
+
raw = options&.fetch(:raw, false)
|
344
|
+
deserialize_entry(redis.with { |c| c.get(key) }, raw: raw)
|
352
345
|
end
|
353
346
|
end
|
354
347
|
|
355
|
-
def read_multi_entries(names,
|
348
|
+
def read_multi_entries(names, **options)
|
356
349
|
if mget_capable?
|
357
350
|
read_multi_mget(*names)
|
358
351
|
else
|
@@ -364,6 +357,7 @@ module ActiveSupport
|
|
364
357
|
options = names.extract_options!
|
365
358
|
options = merged_options(options)
|
366
359
|
return {} if names == []
|
360
|
+
raw = options&.fetch(:raw, false)
|
367
361
|
|
368
362
|
keys = names.map { |name| normalize_key(name, options) }
|
369
363
|
|
@@ -373,7 +367,7 @@ module ActiveSupport
|
|
373
367
|
|
374
368
|
names.zip(values).each_with_object({}) do |(name, value), results|
|
375
369
|
if value
|
376
|
-
entry = deserialize_entry(value)
|
370
|
+
entry = deserialize_entry(value, raw: raw)
|
377
371
|
unless entry.nil? || entry.expired? || entry.mismatched?(normalize_version(name, options))
|
378
372
|
results[name] = entry.value
|
379
373
|
end
|
@@ -448,9 +442,20 @@ module ActiveSupport
|
|
448
442
|
end
|
449
443
|
end
|
450
444
|
|
451
|
-
def deserialize_entry(serialized_entry)
|
445
|
+
def deserialize_entry(serialized_entry, raw:)
|
452
446
|
if serialized_entry
|
453
447
|
entry = Marshal.load(serialized_entry) rescue serialized_entry
|
448
|
+
|
449
|
+
written_raw = serialized_entry.equal?(entry)
|
450
|
+
if raw != written_raw
|
451
|
+
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
452
|
+
Using a different value for the raw option when reading and writing
|
453
|
+
to a cache key is deprecated for :redis_cache_store and Rails 6.0
|
454
|
+
will stop automatically detecting the format when reading to avoid
|
455
|
+
marshal loading untrusted raw strings.
|
456
|
+
MSG
|
457
|
+
end
|
458
|
+
|
454
459
|
entry.is_a?(Entry) ? entry : Entry.new(entry)
|
455
460
|
end
|
456
461
|
end
|
@@ -50,27 +50,27 @@ module ActiveSupport
|
|
50
50
|
@data.clear
|
51
51
|
end
|
52
52
|
|
53
|
-
def read_entry(key, options)
|
53
|
+
def read_entry(key, **options)
|
54
54
|
@data[key]
|
55
55
|
end
|
56
56
|
|
57
|
-
def read_multi_entries(keys, options)
|
57
|
+
def read_multi_entries(keys, **options)
|
58
58
|
values = {}
|
59
59
|
|
60
60
|
keys.each do |name|
|
61
|
-
entry = read_entry(name, options)
|
61
|
+
entry = read_entry(name, **options)
|
62
62
|
values[name] = entry.value if entry
|
63
63
|
end
|
64
64
|
|
65
65
|
values
|
66
66
|
end
|
67
67
|
|
68
|
-
def write_entry(key, value, options)
|
68
|
+
def write_entry(key, value, **options)
|
69
69
|
@data[key] = value
|
70
70
|
true
|
71
71
|
end
|
72
72
|
|
73
|
-
def delete_entry(key, options)
|
73
|
+
def delete_entry(key, **options)
|
74
74
|
!!@data.delete(key)
|
75
75
|
end
|
76
76
|
|
@@ -92,34 +92,34 @@ module ActiveSupport
|
|
92
92
|
local_cache_key)
|
93
93
|
end
|
94
94
|
|
95
|
-
def clear(options
|
95
|
+
def clear(**options) # :nodoc:
|
96
96
|
return super unless cache = local_cache
|
97
97
|
cache.clear(options)
|
98
98
|
super
|
99
99
|
end
|
100
100
|
|
101
|
-
def cleanup(options
|
101
|
+
def cleanup(**options) # :nodoc:
|
102
102
|
return super unless cache = local_cache
|
103
103
|
cache.clear
|
104
104
|
super
|
105
105
|
end
|
106
106
|
|
107
|
-
def increment(name, amount = 1, options
|
107
|
+
def increment(name, amount = 1, **options) # :nodoc:
|
108
108
|
return super unless local_cache
|
109
109
|
value = bypass_local_cache { super }
|
110
|
-
write_cache_value(name, value, options)
|
110
|
+
write_cache_value(name, value, **options)
|
111
111
|
value
|
112
112
|
end
|
113
113
|
|
114
|
-
def decrement(name, amount = 1, options
|
114
|
+
def decrement(name, amount = 1, **options) # :nodoc:
|
115
115
|
return super unless local_cache
|
116
116
|
value = bypass_local_cache { super }
|
117
|
-
write_cache_value(name, value, options)
|
117
|
+
write_cache_value(name, value, **options)
|
118
118
|
value
|
119
119
|
end
|
120
120
|
|
121
121
|
private
|
122
|
-
def read_entry(key, options)
|
122
|
+
def read_entry(key, **options)
|
123
123
|
if cache = local_cache
|
124
124
|
cache.fetch_entry(key) { super }
|
125
125
|
else
|
@@ -127,42 +127,42 @@ module ActiveSupport
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
def read_multi_entries(keys, options)
|
130
|
+
def read_multi_entries(keys, **options)
|
131
131
|
return super unless local_cache
|
132
132
|
|
133
|
-
local_entries = local_cache.read_multi_entries(keys, options)
|
133
|
+
local_entries = local_cache.read_multi_entries(keys, **options)
|
134
134
|
missed_keys = keys - local_entries.keys
|
135
135
|
|
136
136
|
if missed_keys.any?
|
137
|
-
local_entries.merge!(super(missed_keys, options))
|
137
|
+
local_entries.merge!(super(missed_keys, **options))
|
138
138
|
else
|
139
139
|
local_entries
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
-
def write_entry(key, entry, options)
|
143
|
+
def write_entry(key, entry, **options)
|
144
144
|
if options[:unless_exist]
|
145
|
-
local_cache.delete_entry(key, options) if local_cache
|
145
|
+
local_cache.delete_entry(key, **options) if local_cache
|
146
146
|
else
|
147
|
-
local_cache.write_entry(key, entry, options) if local_cache
|
147
|
+
local_cache.write_entry(key, entry, **options) if local_cache
|
148
148
|
end
|
149
149
|
|
150
150
|
super
|
151
151
|
end
|
152
152
|
|
153
|
-
def delete_entry(key, options)
|
154
|
-
local_cache.delete_entry(key, options) if local_cache
|
153
|
+
def delete_entry(key, **options)
|
154
|
+
local_cache.delete_entry(key, **options) if local_cache
|
155
155
|
super
|
156
156
|
end
|
157
157
|
|
158
|
-
def write_cache_value(name, value, options)
|
158
|
+
def write_cache_value(name, value, **options)
|
159
159
|
name = normalize_key(name, options)
|
160
160
|
cache = local_cache
|
161
161
|
cache.mute do
|
162
162
|
if value
|
163
|
-
cache.write(name, value, options)
|
163
|
+
cache.write(name, value, **options)
|
164
164
|
else
|
165
|
-
cache.delete(name, options)
|
165
|
+
cache.delete(name, **options)
|
166
166
|
end
|
167
167
|
end
|
168
168
|
end
|
@@ -142,7 +142,6 @@ module ActiveSupport
|
|
142
142
|
end
|
143
143
|
|
144
144
|
private
|
145
|
-
|
146
145
|
# A hook invoked every time a before callback is halted.
|
147
146
|
# This can be overridden in ActiveSupport::Callbacks implementors in order
|
148
147
|
# to provide better debugging/logging.
|
@@ -582,7 +581,6 @@ module ActiveSupport
|
|
582
581
|
attr_reader :chain
|
583
582
|
|
584
583
|
private
|
585
|
-
|
586
584
|
def append_one(callback)
|
587
585
|
@callbacks = nil
|
588
586
|
remove_duplicates(callback)
|
@@ -843,7 +841,6 @@ module ActiveSupport
|
|
843
841
|
end
|
844
842
|
|
845
843
|
protected
|
846
|
-
|
847
844
|
def get_callbacks(name) # :nodoc:
|
848
845
|
__callbacks[name.to_sym]
|
849
846
|
end
|
@@ -7,11 +7,29 @@ module ActiveSupport
|
|
7
7
|
# A monitor that will permit dependency loading while blocked waiting for
|
8
8
|
# the lock.
|
9
9
|
class LoadInterlockAwareMonitor < Monitor
|
10
|
+
EXCEPTION_NEVER = { Exception => :never }.freeze
|
11
|
+
EXCEPTION_IMMEDIATE = { Exception => :immediate }.freeze
|
12
|
+
private_constant :EXCEPTION_NEVER, :EXCEPTION_IMMEDIATE
|
13
|
+
|
10
14
|
# Enters an exclusive section, but allows dependency loading while blocked
|
11
15
|
def mon_enter
|
12
16
|
mon_try_enter ||
|
13
17
|
ActiveSupport::Dependencies.interlock.permit_concurrent_loads { super }
|
14
18
|
end
|
19
|
+
|
20
|
+
def synchronize
|
21
|
+
Thread.handle_interrupt(EXCEPTION_NEVER) do
|
22
|
+
mon_enter
|
23
|
+
|
24
|
+
begin
|
25
|
+
Thread.handle_interrupt(EXCEPTION_IMMEDIATE) do
|
26
|
+
yield
|
27
|
+
end
|
28
|
+
ensure
|
29
|
+
mon_exit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
15
33
|
end
|
16
34
|
end
|
17
35
|
end
|
@@ -74,13 +74,13 @@ class Array
|
|
74
74
|
|
75
75
|
case length
|
76
76
|
when 0
|
77
|
-
""
|
77
|
+
+""
|
78
78
|
when 1
|
79
|
-
"#{self[0]}"
|
79
|
+
+"#{self[0]}"
|
80
80
|
when 2
|
81
|
-
"#{self[0]}#{options[:two_words_connector]}#{self[1]}"
|
81
|
+
+"#{self[0]}#{options[:two_words_connector]}#{self[1]}"
|
82
82
|
else
|
83
|
-
"#{self[0...-1].join(options[:words_connector])}#{options[:last_word_connector]}#{self[-1]}"
|
83
|
+
+"#{self[0...-1].join(options[:words_connector])}#{options[:last_word_connector]}#{self[-1]}"
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -181,7 +181,7 @@ class Array
|
|
181
181
|
# </messages>
|
182
182
|
#
|
183
183
|
def to_xml(options = {})
|
184
|
-
require "active_support/builder" unless defined?(Builder)
|
184
|
+
require "active_support/builder" unless defined?(Builder::XmlMarkup)
|
185
185
|
|
186
186
|
options = options.dup
|
187
187
|
options[:indent] ||= 2
|
@@ -73,7 +73,7 @@ class Hash
|
|
73
73
|
# configure your own builder with the <tt>:builder</tt> option. The method also accepts
|
74
74
|
# options like <tt>:dasherize</tt> and friends, they are forwarded to the builder.
|
75
75
|
def to_xml(options = {})
|
76
|
-
require "active_support/builder" unless defined?(Builder)
|
76
|
+
require "active_support/builder" unless defined?(Builder::XmlMarkup)
|
77
77
|
|
78
78
|
options = options.dup
|
79
79
|
options[:indent] ||= 2
|
@@ -193,7 +193,13 @@ class Module
|
|
193
193
|
method_names = methods.map do |method|
|
194
194
|
# Attribute writer methods only accept one argument. Makes sure []=
|
195
195
|
# methods still accept two arguments.
|
196
|
-
definition = /[^\]]=$/.match?(method)
|
196
|
+
definition = if /[^\]]=$/.match?(method)
|
197
|
+
"arg"
|
198
|
+
elsif RUBY_VERSION >= "2.7"
|
199
|
+
"..."
|
200
|
+
else
|
201
|
+
"*args, &block"
|
202
|
+
end
|
197
203
|
|
198
204
|
# The following generated method calls the target exactly once, storing
|
199
205
|
# the returned value in a dummy variable.
|
@@ -308,6 +314,7 @@ class Module
|
|
308
314
|
end
|
309
315
|
end
|
310
316
|
end
|
317
|
+
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
311
318
|
RUBY
|
312
319
|
end
|
313
320
|
end
|
@@ -15,6 +15,7 @@ module ActiveSupport
|
|
15
15
|
public_send(method_name, *args, &b)
|
16
16
|
end
|
17
17
|
end
|
18
|
+
ruby2_keywords(:try) if respond_to?(:ruby2_keywords, true)
|
18
19
|
|
19
20
|
def try!(method_name = nil, *args, &b)
|
20
21
|
if method_name.nil? && block_given?
|
@@ -27,6 +28,7 @@ module ActiveSupport
|
|
27
28
|
public_send(method_name, *args, &b)
|
28
29
|
end
|
29
30
|
end
|
31
|
+
ruby2_keywords(:try!) if respond_to?(:ruby2_keywords, true)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -313,7 +313,6 @@ module ActiveSupport #:nodoc:
|
|
313
313
|
end
|
314
314
|
|
315
315
|
private
|
316
|
-
|
317
316
|
def load(file, wrap = false)
|
318
317
|
result = false
|
319
318
|
load_dependency(file) { result = super }
|
@@ -794,7 +793,6 @@ module ActiveSupport #:nodoc:
|
|
794
793
|
end
|
795
794
|
|
796
795
|
private
|
797
|
-
|
798
796
|
# Returns the original name of a class or module even if `name` has been
|
799
797
|
# overridden.
|
800
798
|
def real_mod_name(mod)
|
@@ -58,15 +58,21 @@ module ActiveSupport
|
|
58
58
|
method_names.each do |method_name|
|
59
59
|
if target_module.method_defined?(method_name) || target_module.private_method_defined?(method_name)
|
60
60
|
method = target_module.instance_method(method_name)
|
61
|
-
target_module.
|
62
|
-
|
63
|
-
|
61
|
+
target_module.module_eval do
|
62
|
+
redefine_method(method_name) do |*args, &block|
|
63
|
+
deprecator.deprecation_warning(method_name, options[method_name])
|
64
|
+
method.bind(self).call(*args, &block)
|
65
|
+
end
|
66
|
+
ruby2_keywords(method_name) if respond_to?(:ruby2_keywords, true)
|
64
67
|
end
|
65
68
|
else
|
66
69
|
mod ||= Module.new
|
67
|
-
mod.
|
68
|
-
|
69
|
-
|
70
|
+
mod.module_eval do
|
71
|
+
define_method(method_name) do |*args, &block|
|
72
|
+
deprecator.deprecation_warning(method_name, options[method_name])
|
73
|
+
super(*args, &block)
|
74
|
+
end
|
75
|
+
ruby2_keywords(method_name) if respond_to?(:ruby2_keywords, true)
|
70
76
|
end
|
71
77
|
end
|
72
78
|
end
|