activesupport 7.0.8 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +801 -292
- data/MIT-LICENSE +1 -1
- data/README.rdoc +4 -4
- data/lib/active_support/actionable_error.rb +3 -1
- data/lib/active_support/array_inquirer.rb +2 -0
- data/lib/active_support/backtrace_cleaner.rb +25 -5
- data/lib/active_support/benchmarkable.rb +1 -0
- data/lib/active_support/broadcast_logger.rb +222 -0
- data/lib/active_support/builder.rb +1 -1
- data/lib/active_support/cache/coder.rb +153 -0
- data/lib/active_support/cache/entry.rb +128 -0
- data/lib/active_support/cache/file_store.rb +36 -9
- data/lib/active_support/cache/mem_cache_store.rb +84 -68
- data/lib/active_support/cache/memory_store.rb +76 -24
- data/lib/active_support/cache/null_store.rb +6 -0
- data/lib/active_support/cache/redis_cache_store.rb +126 -131
- data/lib/active_support/cache/serializer_with_fallback.rb +175 -0
- data/lib/active_support/cache/strategy/local_cache.rb +20 -8
- data/lib/active_support/cache.rb +304 -246
- data/lib/active_support/callbacks.rb +44 -21
- data/lib/active_support/concern.rb +4 -2
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +42 -3
- data/lib/active_support/concurrency/null_lock.rb +13 -0
- data/lib/active_support/configurable.rb +10 -0
- data/lib/active_support/core_ext/array/conversions.rb +2 -1
- data/lib/active_support/core_ext/array.rb +0 -1
- data/lib/active_support/core_ext/class/subclasses.rb +13 -10
- data/lib/active_support/core_ext/date/conversions.rb +1 -0
- data/lib/active_support/core_ext/date.rb +0 -1
- data/lib/active_support/core_ext/date_and_time/calculations.rb +10 -0
- data/lib/active_support/core_ext/date_time/conversions.rb +6 -2
- data/lib/active_support/core_ext/date_time.rb +0 -1
- data/lib/active_support/core_ext/digest/uuid.rb +1 -10
- data/lib/active_support/core_ext/enumerable.rb +3 -75
- data/lib/active_support/core_ext/erb/util.rb +196 -0
- data/lib/active_support/core_ext/hash/conversions.rb +1 -1
- data/lib/active_support/core_ext/hash/deep_merge.rb +22 -14
- data/lib/active_support/core_ext/module/attribute_accessors.rb +6 -0
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +34 -16
- data/lib/active_support/core_ext/module/delegation.rb +40 -11
- data/lib/active_support/core_ext/module/deprecation.rb +15 -12
- data/lib/active_support/core_ext/module/introspection.rb +0 -1
- data/lib/active_support/core_ext/numeric/bytes.rb +9 -0
- data/lib/active_support/core_ext/numeric/conversions.rb +2 -0
- data/lib/active_support/core_ext/numeric.rb +0 -1
- data/lib/active_support/core_ext/object/deep_dup.rb +16 -0
- data/lib/active_support/core_ext/object/inclusion.rb +13 -5
- data/lib/active_support/core_ext/object/instance_variables.rb +22 -12
- data/lib/active_support/core_ext/object/json.rb +10 -2
- data/lib/active_support/core_ext/object/with.rb +44 -0
- data/lib/active_support/core_ext/object/with_options.rb +3 -3
- data/lib/active_support/core_ext/object.rb +1 -0
- data/lib/active_support/core_ext/pathname/blank.rb +16 -0
- data/lib/active_support/core_ext/pathname/existence.rb +2 -0
- data/lib/active_support/core_ext/pathname.rb +1 -0
- data/lib/active_support/core_ext/range/conversions.rb +28 -7
- data/lib/active_support/core_ext/range/overlap.rb +40 -0
- data/lib/active_support/core_ext/range.rb +1 -2
- data/lib/active_support/core_ext/securerandom.rb +24 -12
- data/lib/active_support/core_ext/string/filters.rb +20 -14
- data/lib/active_support/core_ext/string/inflections.rb +16 -5
- data/lib/active_support/core_ext/string/output_safety.rb +38 -174
- data/lib/active_support/core_ext/thread/backtrace/location.rb +12 -0
- data/lib/active_support/core_ext/time/calculations.rb +18 -2
- data/lib/active_support/core_ext/time/conversions.rb +2 -2
- data/lib/active_support/core_ext/time/zones.rb +4 -4
- data/lib/active_support/core_ext/time.rb +0 -1
- data/lib/active_support/current_attributes.rb +15 -6
- data/lib/active_support/deep_mergeable.rb +53 -0
- data/lib/active_support/dependencies/autoload.rb +17 -12
- data/lib/active_support/deprecation/behaviors.rb +53 -32
- data/lib/active_support/deprecation/constant_accessor.rb +5 -4
- data/lib/active_support/deprecation/deprecators.rb +104 -0
- data/lib/active_support/deprecation/disallowed.rb +3 -5
- data/lib/active_support/deprecation/instance_delegator.rb +31 -4
- data/lib/active_support/deprecation/method_wrappers.rb +6 -23
- data/lib/active_support/deprecation/proxy_wrappers.rb +37 -22
- data/lib/active_support/deprecation/reporting.rb +35 -21
- data/lib/active_support/deprecation.rb +32 -5
- data/lib/active_support/deprecator.rb +7 -0
- data/lib/active_support/descendants_tracker.rb +104 -132
- data/lib/active_support/duration/iso8601_serializer.rb +0 -2
- data/lib/active_support/duration.rb +2 -1
- data/lib/active_support/encrypted_configuration.rb +30 -9
- data/lib/active_support/encrypted_file.rb +8 -3
- data/lib/active_support/environment_inquirer.rb +22 -2
- data/lib/active_support/error_reporter/test_helper.rb +15 -0
- data/lib/active_support/error_reporter.rb +121 -35
- data/lib/active_support/execution_wrapper.rb +4 -4
- data/lib/active_support/file_update_checker.rb +4 -2
- data/lib/active_support/fork_tracker.rb +10 -2
- data/lib/active_support/gem_version.rb +3 -3
- data/lib/active_support/gzip.rb +2 -0
- data/lib/active_support/hash_with_indifferent_access.rb +35 -17
- data/lib/active_support/i18n.rb +1 -1
- data/lib/active_support/i18n_railtie.rb +20 -13
- data/lib/active_support/inflector/inflections.rb +2 -0
- data/lib/active_support/inflector/methods.rb +22 -10
- data/lib/active_support/inflector/transliterate.rb +3 -1
- data/lib/active_support/isolated_execution_state.rb +26 -22
- data/lib/active_support/json/decoding.rb +2 -1
- data/lib/active_support/json/encoding.rb +25 -43
- data/lib/active_support/key_generator.rb +9 -1
- data/lib/active_support/lazy_load_hooks.rb +6 -4
- data/lib/active_support/locale/en.yml +2 -0
- data/lib/active_support/log_subscriber.rb +78 -33
- data/lib/active_support/logger.rb +9 -60
- data/lib/active_support/logger_thread_safe_level.rb +10 -24
- data/lib/active_support/message_encryptor.rb +197 -53
- data/lib/active_support/message_encryptors.rb +140 -0
- data/lib/active_support/message_pack/cache_serializer.rb +23 -0
- data/lib/active_support/message_pack/extensions.rb +292 -0
- data/lib/active_support/message_pack/serializer.rb +63 -0
- data/lib/active_support/message_pack.rb +50 -0
- data/lib/active_support/message_verifier.rb +212 -93
- data/lib/active_support/message_verifiers.rb +134 -0
- data/lib/active_support/messages/codec.rb +65 -0
- data/lib/active_support/messages/metadata.rb +111 -45
- data/lib/active_support/messages/rotation_coordinator.rb +93 -0
- data/lib/active_support/messages/rotator.rb +34 -32
- data/lib/active_support/messages/serializer_with_fallback.rb +158 -0
- data/lib/active_support/multibyte/chars.rb +2 -0
- data/lib/active_support/multibyte/unicode.rb +9 -37
- data/lib/active_support/notifications/fanout.rb +239 -81
- data/lib/active_support/notifications/instrumenter.rb +71 -14
- data/lib/active_support/notifications.rb +1 -1
- data/lib/active_support/number_helper/number_converter.rb +12 -5
- data/lib/active_support/number_helper/number_to_currency_converter.rb +6 -6
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -0
- data/lib/active_support/ordered_hash.rb +3 -3
- data/lib/active_support/ordered_options.rb +14 -0
- data/lib/active_support/parameter_filter.rb +84 -69
- data/lib/active_support/proxy_object.rb +2 -0
- data/lib/active_support/railtie.rb +33 -21
- data/lib/active_support/reloader.rb +12 -4
- data/lib/active_support/rescuable.rb +2 -0
- data/lib/active_support/secure_compare_rotator.rb +16 -9
- data/lib/active_support/string_inquirer.rb +3 -1
- data/lib/active_support/subscriber.rb +9 -27
- data/lib/active_support/syntax_error_proxy.rb +49 -0
- data/lib/active_support/tagged_logging.rb +60 -24
- data/lib/active_support/test_case.rb +153 -6
- data/lib/active_support/testing/assertions.rb +25 -9
- data/lib/active_support/testing/autorun.rb +0 -2
- data/lib/active_support/testing/constant_stubbing.rb +32 -0
- data/lib/active_support/testing/deprecation.rb +25 -25
- data/lib/active_support/testing/error_reporter_assertions.rb +107 -0
- data/lib/active_support/testing/isolation.rb +1 -1
- data/lib/active_support/testing/method_call_assertions.rb +21 -8
- data/lib/active_support/testing/parallelize_executor.rb +8 -3
- data/lib/active_support/testing/stream.rb +1 -1
- data/lib/active_support/testing/strict_warnings.rb +38 -0
- data/lib/active_support/testing/time_helpers.rb +32 -14
- data/lib/active_support/time_with_zone.rb +4 -14
- data/lib/active_support/values/time_zone.rb +9 -7
- data/lib/active_support/version.rb +1 -1
- data/lib/active_support/xml_mini/jdom.rb +3 -10
- data/lib/active_support/xml_mini/nokogiri.rb +1 -1
- data/lib/active_support/xml_mini/nokogirisax.rb +1 -1
- data/lib/active_support/xml_mini/rexml.rb +1 -1
- data/lib/active_support/xml_mini.rb +2 -2
- data/lib/active_support.rb +14 -3
- metadata +102 -15
- data/lib/active_support/core_ext/array/deprecated_conversions.rb +0 -25
- data/lib/active_support/core_ext/date/deprecated_conversions.rb +0 -40
- data/lib/active_support/core_ext/date_time/deprecated_conversions.rb +0 -36
- data/lib/active_support/core_ext/numeric/deprecated_conversions.rb +0 -60
- data/lib/active_support/core_ext/range/deprecated_conversions.rb +0 -36
- data/lib/active_support/core_ext/range/include_time_with_zone.rb +0 -5
- data/lib/active_support/core_ext/range/overlaps.rb +0 -10
- data/lib/active_support/core_ext/time/deprecated_conversions.rb +0 -73
- data/lib/active_support/core_ext/uri.rb +0 -5
- data/lib/active_support/per_thread_registry.rb +0 -65
data/CHANGELOG.md
CHANGED
@@ -1,565 +1,1074 @@
|
|
1
|
-
## Rails 7.0
|
1
|
+
## Rails 7.1.0 (October 05, 2023) ##
|
2
2
|
|
3
|
-
*
|
4
|
-
disable it are set.
|
3
|
+
* No changes.
|
5
4
|
|
6
|
-
*Hartley McGuire*
|
7
5
|
|
8
|
-
|
6
|
+
## Rails 7.1.0.rc2 (October 01, 2023) ##
|
9
7
|
|
10
|
-
|
8
|
+
* Fix `AS::MessagePack` with `ENV["RAILS_MAX_THREADS"]`.
|
11
9
|
|
12
|
-
*Jonathan
|
10
|
+
*Jonathan Hefner*
|
13
11
|
|
14
12
|
|
15
|
-
## Rails 7.0.
|
13
|
+
## Rails 7.1.0.rc1 (September 27, 2023) ##
|
16
14
|
|
17
|
-
*
|
15
|
+
* Add a new public API for broadcasting logs
|
18
16
|
|
17
|
+
This feature existed for a while but was until now a private API.
|
18
|
+
Broadcasting log allows to send log message to difference sinks (STDOUT, a file ...) and
|
19
|
+
is used by default in the development environment to write logs both on STDOUT and in the
|
20
|
+
"development.log" file.
|
19
21
|
|
20
|
-
|
22
|
+
Basic usage:
|
21
23
|
|
22
|
-
|
24
|
+
```ruby
|
25
|
+
stdout_logger = Logger.new(STDOUT)
|
26
|
+
file_logger = Logger.new("development.log")
|
27
|
+
broadcast = ActiveSupport::BroadcastLogger.new(stdout_logger, file_logger)
|
23
28
|
|
24
|
-
|
29
|
+
broadcast.info("Hello!") # The "Hello!" message is written on STDOUT and in the log file.
|
30
|
+
```
|
25
31
|
|
32
|
+
Adding other sink(s) to the broadcast:
|
26
33
|
|
27
|
-
|
34
|
+
```ruby
|
35
|
+
broadcast = ActiveSupport::BroadcastLogger.new
|
36
|
+
broadcast.broadcast_to(Logger.new(STDERR))
|
37
|
+
```
|
28
38
|
|
29
|
-
|
39
|
+
Remove a sink from the broadcast:
|
30
40
|
|
31
|
-
|
41
|
+
```ruby
|
42
|
+
stdout_logger = Logger.new(STDOUT)
|
43
|
+
broadcast = ActiveSupport::BroadcastLogger.new(stdout_logger)
|
32
44
|
|
33
|
-
|
45
|
+
broadcast.stop_broadcasting_to(stdout_logger)
|
46
|
+
```
|
34
47
|
|
35
|
-
*
|
48
|
+
*Edouard Chin*
|
36
49
|
|
37
|
-
* Fix
|
50
|
+
* Fix Range#overlap? not taking empty ranges into account on Ruby < 3.3
|
38
51
|
|
39
|
-
*
|
52
|
+
*Nobuyoshi Nakada*, *Shouichi Kamiya*, *Hartley McGuire*
|
40
53
|
|
41
|
-
*
|
54
|
+
* Use Ruby 3.3 Range#overlap? if available
|
42
55
|
|
43
|
-
*
|
56
|
+
*Yasuo Honda*
|
44
57
|
|
45
|
-
* Improve error message when EventedFileUpdateChecker is used without a
|
46
|
-
compatible version of the Listen gem
|
47
58
|
|
48
|
-
|
59
|
+
## Rails 7.1.0.beta1 (September 13, 2023) ##
|
49
60
|
|
61
|
+
* Add `bigdecimal` as Active Support dependency that is a bundled gem candidate for Ruby 3.4.
|
50
62
|
|
51
|
-
|
63
|
+
`bigdecimal` 3.1.4 or higher version will be installed.
|
64
|
+
Ruby 2.7 and 3.0 users who want `bigdecimal` version 2.0.0 or 3.0.0 behavior as a default gem,
|
65
|
+
pin the `bigdecimal` version in your application Gemfile.
|
52
66
|
|
53
|
-
*
|
54
|
-
methods
|
67
|
+
*Koichi ITO*
|
55
68
|
|
56
|
-
|
69
|
+
* Add `drb`, `mutex_m` and `base64` that are bundled gem candidates for Ruby 3.4
|
57
70
|
|
58
|
-
*
|
71
|
+
*Yasuo Honda*
|
59
72
|
|
60
|
-
|
73
|
+
* When using cache format version >= 7.1 or a custom serializer, expired and
|
74
|
+
version-mismatched cache entries can now be detected without deserializing
|
75
|
+
their values.
|
61
76
|
|
62
|
-
*
|
77
|
+
*Jonathan Hefner*
|
63
78
|
|
64
|
-
|
79
|
+
* Make all cache stores return a boolean for `#delete`
|
65
80
|
|
81
|
+
Previously the `RedisCacheStore#delete` would return `1` if the entry
|
82
|
+
exists and `0` otherwise. Now it returns true if the entry exists and false
|
83
|
+
otherwise, just like the other stores.
|
66
84
|
|
67
|
-
|
85
|
+
The `FileStore` would return `nil` if the entry doesn't exists and returns
|
86
|
+
`false` now as well.
|
68
87
|
|
69
|
-
*
|
88
|
+
*Petrik de Heus*
|
70
89
|
|
90
|
+
* Active Support cache stores now support replacing the default compressor via
|
91
|
+
a `:compressor` option. The specified compressor must respond to `deflate`
|
92
|
+
and `inflate`. For example:
|
71
93
|
|
72
|
-
|
94
|
+
```ruby
|
95
|
+
module MyCompressor
|
96
|
+
def self.deflate(string)
|
97
|
+
# compression logic...
|
98
|
+
end
|
73
99
|
|
74
|
-
|
100
|
+
def self.inflate(compressed)
|
101
|
+
# decompression logic...
|
102
|
+
end
|
103
|
+
end
|
75
104
|
|
76
|
-
|
105
|
+
config.cache_store = :redis_cache_store, { compressor: MyCompressor }
|
106
|
+
```
|
77
107
|
|
108
|
+
*Jonathan Hefner*
|
78
109
|
|
79
|
-
|
110
|
+
* Active Support cache stores now support a `:serializer` option. Similar to
|
111
|
+
the `:coder` option, serializers must respond to `dump` and `load`. However,
|
112
|
+
serializers are only responsible for serializing a cached value, whereas
|
113
|
+
coders are responsible for serializing the entire `ActiveSupport::Cache::Entry`
|
114
|
+
instance. Additionally, the output from serializers can be automatically
|
115
|
+
compressed, whereas coders are responsible for their own compression.
|
80
116
|
|
81
|
-
|
117
|
+
Specifying a serializer instead of a coder also enables performance
|
118
|
+
optimizations, including the bare string optimization introduced by cache
|
119
|
+
format version 7.1.
|
82
120
|
|
83
|
-
|
121
|
+
The `:serializer` and `:coder` options are mutually exclusive. Specifying
|
122
|
+
both will raise an `ArgumentError`.
|
84
123
|
|
124
|
+
*Jonathan Hefner*
|
85
125
|
|
86
|
-
|
126
|
+
* Fix `ActiveSupport::Inflector.humanize(nil)` raising ``NoMethodError: undefined method `end_with?' for nil:NilClass``.
|
87
127
|
|
88
|
-
*
|
128
|
+
*James Robinson*
|
89
129
|
|
130
|
+
* Don't show secrets for `ActiveSupport::KeyGenerator#inspect`.
|
90
131
|
|
91
|
-
|
132
|
+
Before:
|
92
133
|
|
93
|
-
|
134
|
+
```ruby
|
135
|
+
ActiveSupport::KeyGenerator.new(secret).inspect
|
136
|
+
"#<ActiveSupport::KeyGenerator:0x0000000104888038 ... @secret=\"\\xAF\\bFh]LV}q\\nl\\xB2U\\xB3 ... >"
|
137
|
+
```
|
94
138
|
|
95
|
-
|
139
|
+
After:
|
96
140
|
|
141
|
+
```ruby
|
142
|
+
ActiveSupport::KeyGenerator::Aes256Gcm(secret).inspect
|
143
|
+
"#<ActiveSupport::KeyGenerator:0x0000000104888038>"
|
144
|
+
```
|
97
145
|
|
98
|
-
|
146
|
+
*Petrik de Heus*
|
99
147
|
|
100
|
-
*
|
148
|
+
* Improve error message when EventedFileUpdateChecker is used without a
|
149
|
+
compatible version of the Listen gem
|
101
150
|
|
102
|
-
|
103
|
-
process closed the read end, wrote to it, and then terminated (which
|
104
|
-
presumably closed the file descriptors on its end). The parent process
|
105
|
-
closed the write end, read from it, and returned, never closing the read
|
106
|
-
end.
|
151
|
+
*Hartley McGuire*
|
107
152
|
|
108
|
-
|
109
|
-
cause errors if the limit is reached.
|
153
|
+
* Add `:report` behavior for Deprecation
|
110
154
|
|
111
|
-
|
155
|
+
Setting `config.active_support.deprecation = :report` uses the error
|
156
|
+
reporter to report deprecation warnings to `ActiveSupport::ErrorReporter`.
|
112
157
|
|
113
|
-
|
158
|
+
Deprecations are reported as handled errors, with a severity of `:warning`.
|
114
159
|
|
115
|
-
|
160
|
+
Useful to report deprecations happening in production to your bug tracker.
|
116
161
|
|
117
|
-
|
162
|
+
*Étienne Barrié*
|
118
163
|
|
119
|
-
|
120
|
-
that responds to `call`, but in fact its internal implementation assumed that
|
121
|
-
this object could respond to `arity`, so it was restricted to only `Proc` objects.
|
164
|
+
* Rename `Range#overlaps?` to `#overlap?` and add alias for backwards compatibility
|
122
165
|
|
123
|
-
|
166
|
+
*Christian Schmidt*
|
124
167
|
|
125
|
-
|
168
|
+
* Fix `EncryptedConfiguration` returning incorrect values for some `Hash`
|
169
|
+
methods
|
126
170
|
|
171
|
+
*Hartley McGuire*
|
127
172
|
|
128
|
-
|
173
|
+
* Don't show secrets for `MessageEncryptor#inspect`.
|
129
174
|
|
130
|
-
|
175
|
+
Before:
|
131
176
|
|
177
|
+
```ruby
|
178
|
+
ActiveSupport::MessageEncryptor.new(secret, cipher: "aes-256-gcm").inspect
|
179
|
+
"#<ActiveSupport::MessageEncryptor:0x0000000104888038 ... @secret=\"\\xAF\\bFh]LV}q\\nl\\xB2U\\xB3 ... >"
|
180
|
+
```
|
132
181
|
|
133
|
-
|
182
|
+
After:
|
134
183
|
|
135
|
-
|
184
|
+
```ruby
|
185
|
+
ActiveSupport::MessageEncryptor.new(secret, cipher: "aes-256-gcm").inspect
|
186
|
+
"#<ActiveSupport::MessageEncryptor:0x0000000104888038>"
|
187
|
+
```
|
136
188
|
|
189
|
+
*Petrik de Heus*
|
137
190
|
|
138
|
-
|
191
|
+
* Don't show contents for `EncryptedConfiguration#inspect`.
|
139
192
|
|
140
|
-
|
193
|
+
Before:
|
194
|
+
```ruby
|
195
|
+
Rails.application.credentials.inspect
|
196
|
+
"#<ActiveSupport::EncryptedConfiguration:0x000000010d2b38e8 ... @config={:secret=>\"something secret\"} ... @key_file_contents=\"915e4ea054e011022398dc242\" ...>"
|
197
|
+
```
|
141
198
|
|
142
|
-
|
143
|
-
|
199
|
+
After:
|
200
|
+
```ruby
|
201
|
+
Rails.application.credentials.inspect
|
202
|
+
"#<ActiveSupport::EncryptedConfiguration:0x000000010d2b38e8>"
|
203
|
+
```
|
144
204
|
|
145
|
-
|
205
|
+
*Petrik de Heus*
|
146
206
|
|
147
|
-
|
207
|
+
* `ERB::Util.html_escape_once` always returns an `html_safe` string.
|
148
208
|
|
149
|
-
|
209
|
+
This method previously maintained the `html_safe?` property of a string on the return
|
210
|
+
value. Because this string has been escaped, however, not marking it as `html_safe` causes
|
211
|
+
entities to be double-escaped.
|
150
212
|
|
213
|
+
As an example, take this view snippet:
|
151
214
|
|
152
|
-
|
215
|
+
```html
|
216
|
+
<p><%= html_escape_once("this & that & the other") %></p>
|
217
|
+
```
|
153
218
|
|
154
|
-
|
219
|
+
Before this change, that would be double-escaped and render as:
|
155
220
|
|
221
|
+
```html
|
222
|
+
<p>this &amp; that &amp; the other</p>
|
223
|
+
```
|
156
224
|
|
157
|
-
|
225
|
+
After this change, it renders correctly as:
|
158
226
|
|
159
|
-
|
227
|
+
```html
|
228
|
+
<p>this & that & the other</p>
|
229
|
+
```
|
160
230
|
|
231
|
+
Fixes #48256
|
161
232
|
|
162
|
-
|
233
|
+
*Mike Dalessio*
|
163
234
|
|
164
|
-
*
|
235
|
+
* Deprecate `SafeBuffer#clone_empty`.
|
165
236
|
|
166
|
-
|
237
|
+
This method has not been used internally since Rails 4.2.0.
|
167
238
|
|
168
|
-
*
|
239
|
+
*Mike Dalessio*
|
169
240
|
|
170
|
-
|
241
|
+
* `MessageEncryptor`, `MessageVerifier`, and `config.active_support.message_serializer`
|
242
|
+
now accept `:message_pack` and `:message_pack_allow_marshal` as serializers.
|
243
|
+
These serializers require the [`msgpack` gem](https://rubygems.org/gems/msgpack)
|
244
|
+
(>= 1.7.0).
|
171
245
|
|
246
|
+
The Message Pack format can provide improved performance and smaller payload
|
247
|
+
sizes. It also supports round-tripping some Ruby types that are not supported
|
248
|
+
by JSON. For example:
|
172
249
|
|
173
|
-
|
250
|
+
```ruby
|
251
|
+
verifier = ActiveSupport::MessageVerifier.new("secret")
|
252
|
+
data = [{ a: 1 }, { b: 2 }.with_indifferent_access, 1.to_d, Time.at(0, 123)]
|
253
|
+
message = verifier.generate(data)
|
174
254
|
|
175
|
-
|
255
|
+
# BEFORE with config.active_support.message_serializer = :json
|
256
|
+
verifier.verified(message)
|
257
|
+
# => [{"a"=>1}, {"b"=>2}, "1.0", "1969-12-31T18:00:00.000-06:00"]
|
258
|
+
verifier.verified(message).map(&:class)
|
259
|
+
# => [Hash, Hash, String, String]
|
176
260
|
|
177
|
-
|
178
|
-
|
261
|
+
# AFTER with config.active_support.message_serializer = :message_pack
|
262
|
+
verifier.verified(message)
|
263
|
+
# => [{:a=>1}, {"b"=>2}, 0.1e1, 1969-12-31 18:00:00.000123 -0600]
|
264
|
+
verifier.verified(message).map(&:class)
|
265
|
+
# => [Hash, ActiveSupport::HashWithIndifferentAccess, BigDecimal, Time]
|
266
|
+
```
|
179
267
|
|
180
|
-
|
268
|
+
The `:message_pack` serializer can fall back to deserializing with
|
269
|
+
`ActiveSupport::JSON` when necessary, and the `:message_pack_allow_marshal`
|
270
|
+
serializer can fall back to deserializing with `Marshal` as well as
|
271
|
+
`ActiveSupport::JSON`. Additionally, the `:marshal`, `:json`, and
|
272
|
+
`:json_allow_marshal` serializers can now fall back to deserializing with
|
273
|
+
`ActiveSupport::MessagePack` when necessary. These behaviors ensure old
|
274
|
+
messages can still be read so that migration is easier.
|
181
275
|
|
276
|
+
*Jonathan Hefner*
|
182
277
|
|
183
|
-
|
278
|
+
* A new `7.1` cache format is available which includes an optimization for
|
279
|
+
bare string values such as view fragments.
|
184
280
|
|
185
|
-
|
281
|
+
The `7.1` cache format is used by default for new apps, and existing apps
|
282
|
+
can enable the format by setting `config.load_defaults 7.1` or by setting
|
283
|
+
`config.active_support.cache_format_version = 7.1` in `config/application.rb`
|
284
|
+
or a `config/environments/*.rb` file.
|
186
285
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
286
|
+
Cache entries written using the `6.1` or `7.0` cache formats can be read
|
287
|
+
when using the `7.1` format. To perform a rolling deploy of a Rails 7.1
|
288
|
+
upgrade, wherein servers that have not yet been upgraded must be able to
|
289
|
+
read caches from upgraded servers, leave the cache format unchanged on the
|
290
|
+
first deploy, then enable the `7.1` cache format on a subsequent deploy.
|
191
291
|
|
192
|
-
*
|
292
|
+
*Jonathan Hefner*
|
193
293
|
|
294
|
+
* Active Support cache stores can now use a preconfigured serializer based on
|
295
|
+
`ActiveSupport::MessagePack` via the `:serializer` option:
|
194
296
|
|
195
|
-
|
297
|
+
```ruby
|
298
|
+
config.cache_store = :redis_cache_store, { serializer: :message_pack }
|
299
|
+
```
|
196
300
|
|
197
|
-
|
301
|
+
The `:message_pack` serializer can reduce cache entry sizes and improve
|
302
|
+
performance, but requires the [`msgpack` gem](https://rubygems.org/gems/msgpack)
|
303
|
+
(>= 1.7.0).
|
198
304
|
|
305
|
+
The `:message_pack` serializer can read cache entries written by the default
|
306
|
+
serializer, and the default serializer can now read entries written by the
|
307
|
+
`:message_pack` serializer. These behaviors make it easy to migrate between
|
308
|
+
serializer without invalidating the entire cache.
|
199
309
|
|
200
|
-
|
310
|
+
*Jonathan Hefner*
|
201
311
|
|
202
|
-
*
|
312
|
+
* `Object#deep_dup` no longer duplicate named classes and modules.
|
203
313
|
|
204
|
-
|
314
|
+
Before:
|
205
315
|
|
206
|
-
|
207
|
-
|
316
|
+
```ruby
|
317
|
+
hash = { class: Object, module: Kernel }
|
318
|
+
hash.deep_dup # => {:class=>#<Class:0x00000001063ffc80>, :module=>#<Module:0x00000001063ffa00>}
|
319
|
+
```
|
208
320
|
|
209
|
-
|
321
|
+
After:
|
322
|
+
|
323
|
+
```ruby
|
324
|
+
hash = { class: Object, module: Kernel }
|
325
|
+
hash.deep_dup # => {:class=>Object, :module=>Kernel}
|
326
|
+
```
|
327
|
+
|
328
|
+
*Jean Boussier*
|
329
|
+
|
330
|
+
* Consistently raise an `ArgumentError` if the `ActiveSupport::Cache` key is blank.
|
210
331
|
|
211
|
-
*
|
332
|
+
*Joshua Young*
|
212
333
|
|
213
|
-
|
334
|
+
* Deprecate usage of the singleton `ActiveSupport::Deprecation`.
|
214
335
|
|
215
|
-
|
336
|
+
All usage of `ActiveSupport::Deprecation` as a singleton is deprecated, the most common one being
|
337
|
+
`ActiveSupport::Deprecation.warn`. Gem authors should now create their own deprecator (`ActiveSupport::Deprecation`
|
338
|
+
object), and use it to emit deprecation warnings.
|
339
|
+
|
340
|
+
Calling any of the following without specifying a deprecator argument is also deprecated:
|
341
|
+
* Module.deprecate
|
342
|
+
* deprecate_constant
|
343
|
+
* DeprecatedObjectProxy
|
344
|
+
* DeprecatedInstanceVariableProxy
|
345
|
+
* DeprecatedConstantProxy
|
346
|
+
* deprecation-related test assertions
|
347
|
+
|
348
|
+
Use of `ActiveSupport::Deprecation.silence` and configuration methods like `behavior=`, `disallowed_behavior=`,
|
349
|
+
`disallowed_warnings=` should now be aimed at the [application's deprecators](https://api.rubyonrails.org/classes/Rails/Application.html#method-i-deprecators).
|
216
350
|
|
217
351
|
```ruby
|
218
|
-
|
352
|
+
Rails.application.deprecators.silence do
|
353
|
+
# code that emits deprecation warnings
|
354
|
+
end
|
219
355
|
```
|
220
356
|
|
221
|
-
|
357
|
+
If your gem has a Railtie or Engine, it's encouraged to add your deprecator to the application's deprecators, that
|
358
|
+
way the deprecation related configuration options will apply to it as well, e.g.
|
359
|
+
`config.active_support.report_deprecations` set to `false` in the production environment will also disable your
|
360
|
+
deprecator.
|
361
|
+
|
362
|
+
```ruby
|
363
|
+
initializer "my_gem.deprecator" do |app|
|
364
|
+
app.deprecators[:my_gem] = MyGem.deprecator
|
365
|
+
end
|
366
|
+
```
|
367
|
+
|
368
|
+
*Étienne Barrié*
|
369
|
+
|
370
|
+
* Add `Object#with` to set and restore public attributes around a block
|
371
|
+
|
372
|
+
```ruby
|
373
|
+
client.timeout # => 5
|
374
|
+
client.with(timeout: 1) do
|
375
|
+
client.timeout # => 1
|
376
|
+
end
|
377
|
+
client.timeout # => 5
|
378
|
+
```
|
379
|
+
|
380
|
+
*Jean Boussier*
|
381
|
+
|
382
|
+
* Remove deprecated support to generate incorrect RFC 4122 UUIDs when providing a namespace ID that is not one of the
|
383
|
+
constants defined on `Digest::UUID`.
|
384
|
+
|
385
|
+
*Rafael Mendonça França*
|
222
386
|
|
223
|
-
*
|
387
|
+
* Deprecate `config.active_support.use_rfc4122_namespaced_uuids`.
|
224
388
|
|
225
389
|
*Rafael Mendonça França*
|
226
390
|
|
227
|
-
* Remove
|
228
|
-
a date time range is deprecated.
|
391
|
+
* Remove implicit conversion of objects into `String` by `ActiveSupport::SafeBuffer`.
|
229
392
|
|
230
393
|
*Rafael Mendonça França*
|
231
394
|
|
232
|
-
* Remove deprecated `
|
395
|
+
* Remove deprecated `active_support/core_ext/range/include_time_with_zone` file.
|
233
396
|
|
234
397
|
*Rafael Mendonça França*
|
235
398
|
|
236
|
-
*
|
399
|
+
* Deprecate `config.active_support.remove_deprecated_time_with_zone_name`.
|
237
400
|
|
238
401
|
*Rafael Mendonça França*
|
239
402
|
|
240
|
-
*
|
241
|
-
`ActiveSupport::OptionMerger` instance.
|
403
|
+
* Remove deprecated override of `ActiveSupport::TimeWithZone.name`.
|
242
404
|
|
243
|
-
*
|
405
|
+
*Rafael Mendonça França*
|
244
406
|
|
245
|
-
* `
|
407
|
+
* Deprecate `config.active_support.disable_to_s_conversion`.
|
246
408
|
|
247
|
-
|
248
|
-
leaking from one test to another.
|
409
|
+
*Rafael Mendonça França*
|
249
410
|
|
250
|
-
|
411
|
+
* Remove deprecated option to passing a format to `#to_s` in `Array`, `Range`, `Date`, `DateTime`, `Time`,
|
412
|
+
`BigDecimal`, `Float` and, `Integer`.
|
251
413
|
|
252
|
-
|
414
|
+
*Rafael Mendonça França*
|
253
415
|
|
254
|
-
|
416
|
+
* Remove deprecated `ActiveSupport::PerThreadRegistry`.
|
255
417
|
|
256
|
-
*
|
418
|
+
*Rafael Mendonça França*
|
257
419
|
|
258
|
-
|
420
|
+
* Remove deprecated override of `Enumerable#sum`.
|
259
421
|
|
260
|
-
|
422
|
+
*Rafael Mendonça França*
|
261
423
|
|
262
|
-
|
263
|
-
- `ActiveSupport::DescendantsTracker#direct_descendants`
|
424
|
+
* Deprecated initializing a `ActiveSupport::Cache::MemCacheStore` with an instance of `Dalli::Client`.
|
264
425
|
|
265
|
-
|
426
|
+
Deprecate the undocumented option of providing an already-initialized instance of `Dalli::Client` to `ActiveSupport::Cache::MemCacheStore`. Such clients could be configured with unrecognized options, which could lead to unexpected behavior. Instead, provide addresses as documented.
|
266
427
|
|
267
|
-
*
|
428
|
+
*aledustet*
|
268
429
|
|
269
|
-
|
270
|
-
`config.active_support.use_rfc4122_namespaced_uuids` option to `true`
|
271
|
-
and is the default for new apps.
|
430
|
+
* Stub `Time.new()` in `TimeHelpers#travel_to`
|
272
431
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
432
|
+
```ruby
|
433
|
+
travel_to Time.new(2004, 11, 24) do
|
434
|
+
# Inside the `travel_to` block `Time.new` is stubbed
|
435
|
+
assert_equal 2004, Time.new.year
|
436
|
+
end
|
437
|
+
```
|
277
438
|
|
278
|
-
*
|
439
|
+
*fatkodima*
|
279
440
|
|
280
|
-
* `ActiveSupport::
|
281
|
-
|
441
|
+
* Raise `ActiveSupport::MessageEncryptor::InvalidMessage` from
|
442
|
+
`ActiveSupport::MessageEncryptor#decrypt_and_verify` regardless of cipher.
|
443
|
+
Previously, when a `MessageEncryptor` was using a non-AEAD cipher such as
|
444
|
+
AES-256-CBC, a corrupt or tampered message would raise
|
445
|
+
`ActiveSupport::MessageVerifier::InvalidSignature`. Now, all ciphers raise
|
446
|
+
the same error:
|
282
447
|
|
283
|
-
|
448
|
+
```ruby
|
449
|
+
encryptor = ActiveSupport::MessageEncryptor.new("x" * 32, cipher: "aes-256-gcm")
|
450
|
+
message = encryptor.encrypt_and_sign("message")
|
451
|
+
encryptor.decrypt_and_verify(message.next)
|
452
|
+
# => raises ActiveSupport::MessageEncryptor::InvalidMessage
|
284
453
|
|
454
|
+
encryptor = ActiveSupport::MessageEncryptor.new("x" * 32, cipher: "aes-256-cbc")
|
455
|
+
message = encryptor.encrypt_and_sign("message")
|
456
|
+
encryptor.decrypt_and_verify(message.next)
|
457
|
+
# BEFORE:
|
458
|
+
# => raises ActiveSupport::MessageVerifier::InvalidSignature
|
459
|
+
# AFTER:
|
460
|
+
# => raises ActiveSupport::MessageEncryptor::InvalidMessage
|
461
|
+
```
|
285
462
|
|
286
|
-
|
463
|
+
*Jonathan Hefner*
|
287
464
|
|
288
|
-
*
|
465
|
+
* Support `nil` original values when using `ActiveSupport::MessageVerifier#verify`.
|
466
|
+
Previously, `MessageVerifier#verify` did not work with `nil` original
|
467
|
+
values, though both `MessageVerifier#verified` and
|
468
|
+
`MessageEncryptor#decrypt_and_verify` do:
|
289
469
|
|
470
|
+
```ruby
|
471
|
+
encryptor = ActiveSupport::MessageEncryptor.new(secret)
|
472
|
+
message = encryptor.encrypt_and_sign(nil)
|
290
473
|
|
291
|
-
|
474
|
+
encryptor.decrypt_and_verify(message)
|
475
|
+
# => nil
|
292
476
|
|
293
|
-
|
477
|
+
verifier = ActiveSupport::MessageVerifier.new(secret)
|
478
|
+
message = verifier.generate(nil)
|
294
479
|
|
295
|
-
|
480
|
+
verifier.verified(message)
|
481
|
+
# => nil
|
296
482
|
|
297
|
-
|
483
|
+
verifier.verify(message)
|
484
|
+
# BEFORE:
|
485
|
+
# => raises ActiveSupport::MessageVerifier::InvalidSignature
|
486
|
+
# AFTER:
|
487
|
+
# => nil
|
488
|
+
```
|
298
489
|
|
299
|
-
*
|
490
|
+
*Jonathan Hefner*
|
300
491
|
|
301
|
-
*
|
492
|
+
* Maintain `html_safe?` on html_safe strings when sliced with `slice`, `slice!`, or `chr` method.
|
302
493
|
|
303
|
-
|
494
|
+
Previously, `html_safe?` was only maintained when the html_safe strings were sliced
|
495
|
+
with `[]` method. Now, `slice`, `slice!`, and `chr` methods will maintain `html_safe?` like `[]` method.
|
304
496
|
|
305
|
-
|
497
|
+
```ruby
|
498
|
+
string = "<div>test</div>".html_safe
|
499
|
+
string.slice(0, 1).html_safe? # => true
|
500
|
+
string.slice!(0, 1).html_safe? # => true
|
501
|
+
# maintain html_safe? after the slice!
|
502
|
+
string.html_safe? # => true
|
503
|
+
string.chr.html_safe? # => true
|
504
|
+
```
|
306
505
|
|
307
|
-
*
|
506
|
+
*Michael Go*
|
308
507
|
|
309
|
-
*
|
508
|
+
* Add `Object#in?` support for open ranges.
|
310
509
|
|
311
|
-
|
312
|
-
|
313
|
-
|
510
|
+
```ruby
|
511
|
+
assert Date.today.in?(..Date.tomorrow)
|
512
|
+
assert_not Date.today.in?(Date.tomorrow..)
|
513
|
+
```
|
314
514
|
|
315
|
-
*
|
515
|
+
*Ignacio Galindo*
|
316
516
|
|
317
|
-
*
|
517
|
+
* `config.i18n.raise_on_missing_translations = true` now raises on any missing translation.
|
318
518
|
|
319
|
-
Previously
|
320
|
-
|
321
|
-
cause performance issues.
|
519
|
+
Previously it would only raise when called in a view or controller. Now it will raise
|
520
|
+
anytime `I18n.t` is provided an unrecognised key.
|
322
521
|
|
323
|
-
|
522
|
+
If you do not want this behaviour, you can customise the i18n exception handler. See the
|
523
|
+
upgrading guide or i18n guide for more information.
|
524
|
+
|
525
|
+
*Alex Ghiculescu*
|
526
|
+
|
527
|
+
* `ActiveSupport::CurrentAttributes` now raises if a restricted attribute name is used.
|
528
|
+
|
529
|
+
Attributes such as `set` and `reset` cannot be used as they clash with the
|
530
|
+
`CurrentAttributes` public API.
|
531
|
+
|
532
|
+
*Alex Ghiculescu*
|
533
|
+
|
534
|
+
* `HashWithIndifferentAccess#transform_keys` now takes a Hash argument, just
|
535
|
+
as Ruby's `Hash#transform_keys` does.
|
536
|
+
|
537
|
+
*Akira Matsuda*
|
538
|
+
|
539
|
+
* `delegate` now defines method with proper arity when delegating to a Class.
|
540
|
+
With this change, it defines faster method (3.5x faster with no argument).
|
541
|
+
However, in order to gain this benefit, the delegation target method has to
|
542
|
+
be defined before declaring the delegation.
|
324
543
|
|
325
544
|
```ruby
|
326
|
-
|
545
|
+
# This defines 3.5 times faster method than before
|
546
|
+
class C
|
547
|
+
def self.x() end
|
548
|
+
delegate :x, to: :class
|
549
|
+
end
|
550
|
+
|
551
|
+
class C
|
552
|
+
# This works but silently falls back to old behavior because
|
553
|
+
# `delegate` cannot find the definition of `x`
|
554
|
+
delegate :x, to: :class
|
555
|
+
def self.x() end
|
556
|
+
end
|
327
557
|
```
|
328
558
|
|
329
|
-
|
559
|
+
*Akira Matsuda*
|
330
560
|
|
331
|
-
|
332
|
-
|
333
|
-
|
561
|
+
* `assert_difference` message now includes what changed.
|
562
|
+
|
563
|
+
This makes it easier to debug non-obvious failures.
|
564
|
+
|
565
|
+
Before:
|
566
|
+
|
567
|
+
```
|
568
|
+
"User.count" didn't change by 32.
|
569
|
+
Expected: 1611
|
570
|
+
Actual: 1579
|
334
571
|
```
|
335
572
|
|
336
|
-
|
573
|
+
After:
|
337
574
|
|
338
|
-
|
575
|
+
```
|
576
|
+
"User.count" didn't change by 32, but by 0.
|
577
|
+
Expected: 1611
|
578
|
+
Actual: 1579
|
579
|
+
```
|
339
580
|
|
340
|
-
*
|
341
|
-
of them.
|
581
|
+
*Alex Ghiculescu*
|
342
582
|
|
343
|
-
|
344
|
-
setup and fixture loading. Now, Rails will only parallelize test executions when
|
345
|
-
there are enough tests to make it worth it.
|
583
|
+
* Add ability to match exception messages to `assert_raises` assertion
|
346
584
|
|
347
|
-
|
348
|
-
|
585
|
+
Instead of this
|
586
|
+
```ruby
|
587
|
+
error = assert_raises(ArgumentError) do
|
588
|
+
perform_service(param: 'exception')
|
589
|
+
end
|
590
|
+
assert_match(/incorrect param/i, error.message)
|
591
|
+
```
|
349
592
|
|
593
|
+
you can now write this
|
350
594
|
```ruby
|
351
|
-
|
595
|
+
assert_raises(ArgumentError, match: /incorrect param/i) do
|
596
|
+
perform_service(param: 'exception')
|
597
|
+
end
|
352
598
|
```
|
353
599
|
|
354
|
-
|
600
|
+
*fatkodima*
|
601
|
+
|
602
|
+
* Add `Rails.env.local?` shorthand for `Rails.env.development? || Rails.env.test?`.
|
603
|
+
|
604
|
+
*DHH*
|
605
|
+
|
606
|
+
* `ActiveSupport::Testing::TimeHelpers` now accepts named `with_usec` argument
|
607
|
+
to `freeze_time`, `travel`, and `travel_to` methods. Passing true prevents
|
608
|
+
truncating the destination time with `change(usec: 0)`.
|
609
|
+
|
610
|
+
*KevSlashNull*, and *serprex*
|
611
|
+
|
612
|
+
* `ActiveSupport::CurrentAttributes.resets` now accepts a method name
|
613
|
+
|
614
|
+
The block API is still the recommended approach, but now both APIs are supported:
|
355
615
|
|
356
616
|
```ruby
|
357
|
-
class ActiveSupport::
|
358
|
-
|
617
|
+
class Current < ActiveSupport::CurrentAttributes
|
618
|
+
resets { Time.zone = nil }
|
619
|
+
resets :clear_time_zone
|
359
620
|
end
|
360
621
|
```
|
361
622
|
|
362
|
-
*
|
623
|
+
*Alex Ghiculescu*
|
363
624
|
|
364
|
-
*
|
625
|
+
* Ensure `ActiveSupport::Testing::Isolation::Forking` closes pipes
|
365
626
|
|
366
|
-
|
627
|
+
Previously, `Forking.run_in_isolation` opened two ends of a pipe. The fork
|
628
|
+
process closed the read end, wrote to it, and then terminated (which
|
629
|
+
presumably closed the file descriptors on its end). The parent process
|
630
|
+
closed the write end, read from it, and returned, never closing the read
|
631
|
+
end.
|
632
|
+
|
633
|
+
This resulted in an accumulation of open file descriptors, which could
|
634
|
+
cause errors if the limit is reached.
|
635
|
+
|
636
|
+
*Sam Bostock*
|
637
|
+
|
638
|
+
* Fix `Time#change` and `Time#advance` for times around the end of Daylight
|
639
|
+
Saving Time.
|
367
640
|
|
368
|
-
|
369
|
-
|
370
|
-
|
641
|
+
Previously, when `Time#change` or `Time#advance` constructed a time inside
|
642
|
+
the final stretch of Daylight Saving Time (DST), the non-DST offset would
|
643
|
+
always be chosen for local times:
|
371
644
|
|
372
645
|
```ruby
|
373
|
-
|
374
|
-
|
646
|
+
# DST ended just before 2021-11-07 2:00:00 AM in US/Eastern.
|
647
|
+
ENV["TZ"] = "US/Eastern"
|
648
|
+
|
649
|
+
time = Time.local(2021, 11, 07, 00, 59, 59) + 1
|
650
|
+
# => 2021-11-07 01:00:00 -0400
|
651
|
+
time.change(day: 07)
|
652
|
+
# => 2021-11-07 01:00:00 -0500
|
653
|
+
time.advance(seconds: 0)
|
654
|
+
# => 2021-11-07 01:00:00 -0500
|
655
|
+
|
656
|
+
time = Time.local(2021, 11, 06, 01, 00, 00)
|
657
|
+
# => 2021-11-06 01:00:00 -0400
|
658
|
+
time.change(day: 07)
|
659
|
+
# => 2021-11-07 01:00:00 -0500
|
660
|
+
time.advance(days: 1)
|
661
|
+
# => 2021-11-07 01:00:00 -0500
|
375
662
|
```
|
376
663
|
|
377
|
-
|
664
|
+
And the DST offset would always be chosen for times with a `TimeZone`
|
665
|
+
object:
|
378
666
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
667
|
+
```ruby
|
668
|
+
Time.zone = "US/Eastern"
|
669
|
+
|
670
|
+
time = Time.new(2021, 11, 07, 02, 00, 00, Time.zone) - 3600
|
671
|
+
# => 2021-11-07 01:00:00 -0500
|
672
|
+
time.change(day: 07)
|
673
|
+
# => 2021-11-07 01:00:00 -0400
|
674
|
+
time.advance(seconds: 0)
|
675
|
+
# => 2021-11-07 01:00:00 -0400
|
676
|
+
|
677
|
+
time = Time.new(2021, 11, 8, 01, 00, 00, Time.zone)
|
678
|
+
# => 2021-11-08 01:00:00 -0500
|
679
|
+
time.change(day: 07)
|
680
|
+
# => 2021-11-07 01:00:00 -0400
|
681
|
+
time.advance(days: -1)
|
682
|
+
# => 2021-11-07 01:00:00 -0400
|
683
|
+
```
|
384
684
|
|
385
|
-
|
685
|
+
Now, `Time#change` and `Time#advance` will choose the offset that matches
|
686
|
+
the original time's offset when possible:
|
386
687
|
|
387
|
-
|
688
|
+
```ruby
|
689
|
+
ENV["TZ"] = "US/Eastern"
|
690
|
+
|
691
|
+
time = Time.local(2021, 11, 07, 00, 59, 59) + 1
|
692
|
+
# => 2021-11-07 01:00:00 -0400
|
693
|
+
time.change(day: 07)
|
694
|
+
# => 2021-11-07 01:00:00 -0400
|
695
|
+
time.advance(seconds: 0)
|
696
|
+
# => 2021-11-07 01:00:00 -0400
|
697
|
+
|
698
|
+
time = Time.local(2021, 11, 06, 01, 00, 00)
|
699
|
+
# => 2021-11-06 01:00:00 -0400
|
700
|
+
time.change(day: 07)
|
701
|
+
# => 2021-11-07 01:00:00 -0400
|
702
|
+
time.advance(days: 1)
|
703
|
+
# => 2021-11-07 01:00:00 -0400
|
704
|
+
|
705
|
+
Time.zone = "US/Eastern"
|
706
|
+
|
707
|
+
time = Time.new(2021, 11, 07, 02, 00, 00, Time.zone) - 3600
|
708
|
+
# => 2021-11-07 01:00:00 -0500
|
709
|
+
time.change(day: 07)
|
710
|
+
# => 2021-11-07 01:00:00 -0500
|
711
|
+
time.advance(seconds: 0)
|
712
|
+
# => 2021-11-07 01:00:00 -0500
|
713
|
+
|
714
|
+
time = Time.new(2021, 11, 8, 01, 00, 00, Time.zone)
|
715
|
+
# => 2021-11-08 01:00:00 -0500
|
716
|
+
time.change(day: 07)
|
717
|
+
# => 2021-11-07 01:00:00 -0500
|
718
|
+
time.advance(days: -1)
|
719
|
+
# => 2021-11-07 01:00:00 -0500
|
720
|
+
```
|
388
721
|
|
389
|
-
*
|
722
|
+
*Kevin Hall*, *Takayoshi Nishida*, and *Jonathan Hefner*
|
390
723
|
|
391
|
-
*
|
392
|
-
`RAILS_MASTER_KEY` environment variable is blank (e.g. `""`).
|
724
|
+
* Fix MemoryStore to preserve entries TTL when incrementing or decrementing
|
393
725
|
|
394
|
-
|
726
|
+
This is to be more consistent with how MemCachedStore and RedisCacheStore behaves.
|
395
727
|
|
396
|
-
*
|
728
|
+
*Jean Boussier*
|
397
729
|
|
398
|
-
|
730
|
+
* `Rails.error.handle` and `Rails.error.record` filter now by multiple error classes.
|
399
731
|
|
400
732
|
```ruby
|
401
|
-
|
402
|
-
|
733
|
+
Rails.error.handle(IOError, ArgumentError) do
|
734
|
+
1 + '1' # raises TypeError
|
403
735
|
end
|
736
|
+
1 + 1 # TypeErrors are not IOErrors or ArgumentError, so this will *not* be handled
|
404
737
|
```
|
405
738
|
|
406
|
-
*
|
739
|
+
*Martin Spickermann*
|
740
|
+
|
741
|
+
* `Class#subclasses` and `Class#descendants` now automatically filter reloaded classes.
|
407
742
|
|
408
|
-
|
743
|
+
Previously they could return old implementations of reloadable classes that have been
|
744
|
+
dereferenced but not yet garbage collected.
|
409
745
|
|
410
|
-
|
411
|
-
|
412
|
-
circumstances `ActiveSupport::SafeBuffer` was incorrectly calling the
|
413
|
-
explicit conversion method (`#to_s`) on them. This behavior is now
|
414
|
-
deprecated.
|
746
|
+
They now automatically filter such classes like `DescendantTracker#subclasses` and
|
747
|
+
`DescendantTracker#descendants`.
|
415
748
|
|
416
749
|
*Jean Boussier*
|
417
750
|
|
418
|
-
*
|
751
|
+
* `Rails.error.report` now marks errors as reported to avoid reporting them twice.
|
419
752
|
|
420
|
-
|
753
|
+
In some cases, users might want to report errors explicitly with some extra context
|
754
|
+
before letting it bubble up.
|
421
755
|
|
422
|
-
|
756
|
+
This also allows to safely catch and report errors outside of the execution context.
|
423
757
|
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
758
|
+
*Jean Boussier*
|
759
|
+
|
760
|
+
* Add `assert_error_reported` and `assert_no_error_reported`
|
761
|
+
|
762
|
+
Allows to easily asserts an error happened but was handled
|
763
|
+
|
764
|
+
```ruby
|
765
|
+
report = assert_error_reported(IOError) do
|
766
|
+
# ...
|
767
|
+
end
|
768
|
+
assert_equal "Oops", report.error.message
|
769
|
+
assert_equal "admin", report.context[:section]
|
770
|
+
assert_equal :warning, report.severity
|
771
|
+
assert_predicate report, :handled?
|
428
772
|
```
|
429
773
|
|
430
|
-
|
431
|
-
`Rails.application.credentials.aws[:access_key_id]`.
|
774
|
+
*Jean Boussier*
|
432
775
|
|
433
|
-
|
776
|
+
* `ActiveSupport::Deprecation` behavior callbacks can now receive the
|
777
|
+
deprecator instance as an argument. This makes it easier for such callbacks
|
778
|
+
to change their behavior based on the deprecator's state. For example,
|
779
|
+
based on the deprecator's `debug` flag.
|
434
780
|
|
435
|
-
|
781
|
+
3-arity and splat-args callbacks such as the following will now be passed
|
782
|
+
the deprecator instance as their third argument:
|
436
783
|
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
upgrade without invalidating the cache. However Rails 6.1 can't read the
|
441
|
-
new format, so all readers must be upgraded before the new format is enabled.
|
784
|
+
* `->(message, callstack, deprecator) { ... }`
|
785
|
+
* `->(*args) { ... }`
|
786
|
+
* `->(message, *other_args) { ... }`
|
442
787
|
|
443
|
-
|
788
|
+
2-arity and 4-arity callbacks such as the following will continue to behave
|
789
|
+
the same as before:
|
444
790
|
|
445
|
-
*
|
446
|
-
|
447
|
-
|
791
|
+
* `->(message, callstack) { ... }`
|
792
|
+
* `->(message, callstack, deprecation_horizon, gem_name) { ... }`
|
793
|
+
* `->(message, callstack, *deprecation_details) { ... }`
|
448
794
|
|
449
|
-
*
|
795
|
+
*Jonathan Hefner*
|
450
796
|
|
451
|
-
*
|
797
|
+
* `ActiveSupport::Deprecation#disallowed_warnings` now affects the instance on
|
798
|
+
which it is configured.
|
452
799
|
|
453
|
-
|
800
|
+
This means that individual `ActiveSupport::Deprecation` instances can be
|
801
|
+
configured with their own disallowed warnings, and the global
|
802
|
+
`ActiveSupport::Deprecation.disallowed_warnings` now only affects the global
|
803
|
+
`ActiveSupport::Deprecation.warn`.
|
454
804
|
|
455
|
-
|
805
|
+
**Before**
|
456
806
|
|
457
|
-
|
807
|
+
```ruby
|
808
|
+
ActiveSupport::Deprecation.disallowed_warnings = ["foo"]
|
809
|
+
deprecator = ActiveSupport::Deprecation.new("2.0", "MyCoolGem")
|
810
|
+
deprecator.disallowed_warnings = ["bar"]
|
811
|
+
|
812
|
+
ActiveSupport::Deprecation.warn("foo") # => raise ActiveSupport::DeprecationException
|
813
|
+
ActiveSupport::Deprecation.warn("bar") # => print "DEPRECATION WARNING: bar"
|
814
|
+
deprecator.warn("foo") # => raise ActiveSupport::DeprecationException
|
815
|
+
deprecator.warn("bar") # => print "DEPRECATION WARNING: bar"
|
816
|
+
```
|
458
817
|
|
459
|
-
|
460
|
-
instance had fractional seconds the new UTC time instance was out by
|
461
|
-
a factor of 1,000,000 as the `Time.utc` constructor takes a usec
|
462
|
-
value and not a fractional second value.
|
818
|
+
**After**
|
463
819
|
|
464
|
-
|
820
|
+
```ruby
|
821
|
+
ActiveSupport::Deprecation.disallowed_warnings = ["foo"]
|
822
|
+
deprecator = ActiveSupport::Deprecation.new("2.0", "MyCoolGem")
|
823
|
+
deprecator.disallowed_warnings = ["bar"]
|
824
|
+
|
825
|
+
ActiveSupport::Deprecation.warn("foo") # => raise ActiveSupport::DeprecationException
|
826
|
+
ActiveSupport::Deprecation.warn("bar") # => print "DEPRECATION WARNING: bar"
|
827
|
+
deprecator.warn("foo") # => print "DEPRECATION WARNING: foo"
|
828
|
+
deprecator.warn("bar") # => raise ActiveSupport::DeprecationException
|
829
|
+
```
|
830
|
+
|
831
|
+
Note that global `ActiveSupport::Deprecation` methods such as `ActiveSupport::Deprecation.warn`
|
832
|
+
and `ActiveSupport::Deprecation.disallowed_warnings` have been deprecated.
|
833
|
+
|
834
|
+
*Jonathan Hefner*
|
835
|
+
|
836
|
+
* Add italic and underline support to `ActiveSupport::LogSubscriber#color`
|
465
837
|
|
466
|
-
|
838
|
+
Previously, only bold text was supported via a positional argument.
|
839
|
+
This allows for bold, italic, and underline options to be specified
|
840
|
+
for colored logs.
|
467
841
|
|
468
842
|
```ruby
|
469
|
-
|
843
|
+
info color("Hello world!", :red, bold: true, underline: true)
|
470
844
|
```
|
471
845
|
|
846
|
+
*Gannon McGibbon*
|
847
|
+
|
848
|
+
* Add `String#downcase_first` method.
|
849
|
+
|
850
|
+
This method is the corollary of `String#upcase_first`.
|
851
|
+
|
852
|
+
*Mark Schneider*
|
853
|
+
|
854
|
+
* `thread_mattr_accessor` will call `.dup.freeze` on non-frozen default values.
|
855
|
+
|
856
|
+
This provides a basic level of protection against different threads trying
|
857
|
+
to mutate a shared default object.
|
858
|
+
|
859
|
+
*Jonathan Hefner*
|
860
|
+
|
861
|
+
* Add `raise_on_invalid_cache_expiration_time` config to `ActiveSupport::Cache::Store`
|
862
|
+
|
863
|
+
Specifies if an `ArgumentError` should be raised if `Rails.cache` `fetch` or
|
864
|
+
`write` are given an invalid `expires_at` or `expires_in` time.
|
865
|
+
|
866
|
+
Options are `true`, and `false`. If `false`, the exception will be reported
|
867
|
+
as `handled` and logged instead. Defaults to `true` if `config.load_defaults >= 7.1`.
|
868
|
+
|
869
|
+
*Trevor Turk*
|
870
|
+
|
871
|
+
* `ActiveSupport::Cache:Store#fetch` now passes an options accessor to the block.
|
872
|
+
|
873
|
+
It makes possible to override cache options:
|
874
|
+
|
875
|
+
Rails.cache.fetch("3rd-party-token") do |name, options|
|
876
|
+
token = fetch_token_from_remote
|
877
|
+
# set cache's TTL to match token's TTL
|
878
|
+
options.expires_in = token.expires_in
|
879
|
+
token
|
880
|
+
end
|
881
|
+
|
882
|
+
*Andrii Gladkyi*, *Jean Boussier*
|
883
|
+
|
884
|
+
* `default` option of `thread_mattr_accessor` now applies through inheritance and
|
885
|
+
also across new threads.
|
886
|
+
|
887
|
+
Previously, the `default` value provided was set only at the moment of defining
|
888
|
+
the attribute writer, which would cause the attribute to be uninitialized in
|
889
|
+
descendants and in other threads.
|
890
|
+
|
891
|
+
Fixes #43312.
|
892
|
+
|
893
|
+
*Thierry Deo*
|
894
|
+
|
895
|
+
* Redis cache store is now compatible with redis-rb 5.0.
|
896
|
+
|
472
897
|
*Jean Boussier*
|
473
898
|
|
474
|
-
*
|
899
|
+
* Add `skip_nil:` support to `ActiveSupport::Cache::Store#fetch_multi`.
|
475
900
|
|
476
|
-
*
|
901
|
+
*Daniel Alfaro*
|
477
902
|
|
478
|
-
*
|
479
|
-
is considerably faster.
|
903
|
+
* Add `quarter` method to date/time
|
480
904
|
|
481
|
-
|
905
|
+
*Matt Swanson*
|
482
906
|
|
483
|
-
|
484
|
-
%w[foo bar].sum('')
|
485
|
-
# instead of %w[foo bar].sum
|
907
|
+
* Fix `NoMethodError` on custom `ActiveSupport::Deprecation` behavior.
|
486
908
|
|
487
|
-
|
488
|
-
|
489
|
-
|
909
|
+
`ActiveSupport::Deprecation.behavior=` was supposed to accept any object
|
910
|
+
that responds to `call`, but in fact its internal implementation assumed that
|
911
|
+
this object could respond to `arity`, so it was restricted to only `Proc` objects.
|
490
912
|
|
491
|
-
|
913
|
+
This change removes this `arity` restriction of custom behaviors.
|
492
914
|
|
493
|
-
*
|
915
|
+
*Ryo Nakamura*
|
494
916
|
|
495
|
-
|
917
|
+
* Support `:url_safe` option for `MessageEncryptor`.
|
496
918
|
|
497
|
-
|
919
|
+
The `MessageEncryptor` constructor now accepts a `:url_safe` option, similar
|
920
|
+
to the `MessageVerifier` constructor. When enabled, this option ensures
|
921
|
+
that messages use a URL-safe encoding.
|
498
922
|
|
499
|
-
*
|
923
|
+
*Jonathan Hefner*
|
500
924
|
|
501
|
-
|
925
|
+
* Add `url_safe` option to `ActiveSupport::MessageVerifier` initializer
|
502
926
|
|
503
|
-
|
504
|
-
|
927
|
+
`ActiveSupport::MessageVerifier.new` now takes optional `url_safe` argument.
|
928
|
+
It can generate URL-safe strings by passing `url_safe: true`.
|
505
929
|
|
506
930
|
```ruby
|
507
|
-
|
508
|
-
|
509
|
-
payments.minimum(:price) # => 5
|
510
|
-
payments.maximum(:price) # => 15
|
931
|
+
verifier = ActiveSupport::MessageVerifier.new(url_safe: true)
|
932
|
+
message = verifier.generate(data) # => URL-safe string
|
511
933
|
```
|
512
934
|
|
513
|
-
This
|
514
|
-
See PR [#41404](https://github.com/rails/rails/pull/41404) for an example.
|
935
|
+
This option is `false` by default to be backwards compatible.
|
515
936
|
|
516
|
-
*
|
937
|
+
*Shouichi Kamiya*
|
517
938
|
|
518
|
-
*
|
939
|
+
* Enable connection pooling by default for `MemCacheStore` and `RedisCacheStore`.
|
940
|
+
|
941
|
+
If you want to disable connection pooling, set `:pool` option to `false` when configuring the cache store:
|
519
942
|
|
520
943
|
```ruby
|
521
|
-
config.cache_store = :mem_cache_store,
|
944
|
+
config.cache_store = :mem_cache_store, "cache.example.com", pool: false
|
945
|
+
```
|
522
946
|
|
523
|
-
|
947
|
+
*fatkodima*
|
524
948
|
|
525
|
-
|
949
|
+
* Add `force:` support to `ActiveSupport::Cache::Store#fetch_multi`.
|
526
950
|
|
527
|
-
|
951
|
+
*fatkodima*
|
528
952
|
|
529
|
-
|
953
|
+
* Deprecated `:pool_size` and `:pool_timeout` options for configuring connection pooling in cache stores.
|
530
954
|
|
531
|
-
|
955
|
+
Use `pool: true` to enable pooling with default settings:
|
956
|
+
|
957
|
+
```ruby
|
958
|
+
config.cache_store = :redis_cache_store, pool: true
|
532
959
|
```
|
533
960
|
|
534
|
-
|
961
|
+
Or pass individual options via `:pool` option:
|
535
962
|
|
536
|
-
|
963
|
+
```ruby
|
964
|
+
config.cache_store = :redis_cache_store, pool: { size: 10, timeout: 2 }
|
965
|
+
```
|
537
966
|
|
538
|
-
*
|
967
|
+
*fatkodima*
|
539
968
|
|
540
|
-
|
969
|
+
* Allow #increment and #decrement methods of `ActiveSupport::Cache::Store`
|
970
|
+
subclasses to set new values.
|
541
971
|
|
542
|
-
|
543
|
-
|
972
|
+
Previously incrementing or decrementing an unset key would fail and return
|
973
|
+
nil. A default will now be assumed and the key will be created.
|
544
974
|
|
545
|
-
*
|
975
|
+
*Andrej Blagojević*, *Eugene Kenny*
|
976
|
+
|
977
|
+
* Add `skip_nil:` support to `RedisCacheStore`
|
978
|
+
|
979
|
+
*Joey Paris*
|
546
980
|
|
547
|
-
*
|
548
|
-
|
981
|
+
* `ActiveSupport::Cache::MemoryStore#write(name, val, unless_exist:true)` now
|
982
|
+
correctly writes expired keys.
|
549
983
|
|
550
|
-
*
|
984
|
+
*Alan Savage*
|
551
985
|
|
552
|
-
* `
|
986
|
+
* `ActiveSupport::ErrorReporter` now accepts and forward a `source:` parameter.
|
553
987
|
|
554
|
-
|
988
|
+
This allow libraries to signal the origin of the errors, and reporters
|
989
|
+
to easily ignore some sources.
|
555
990
|
|
556
|
-
*
|
991
|
+
*Jean Boussier*
|
992
|
+
|
993
|
+
* Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
|
994
|
+
|
995
|
+
Add the method `ERB::Util.xml_name_escape` to escape dangerous characters
|
996
|
+
in names of tags and names of attributes, following the specification of XML.
|
997
|
+
|
998
|
+
*Álvaro Martín Fraguas*
|
557
999
|
|
558
|
-
|
1000
|
+
* Respect `ActiveSupport::Logger.new`'s `:formatter` keyword argument
|
559
1001
|
|
560
|
-
|
1002
|
+
The stdlib `Logger::new` allows passing a `:formatter` keyword argument to
|
1003
|
+
set the logger's formatter. Previously `ActiveSupport::Logger.new` ignored
|
1004
|
+
that argument by always setting the formatter to an instance of
|
1005
|
+
`ActiveSupport::Logger::SimpleFormatter`.
|
561
1006
|
|
562
|
-
*
|
1007
|
+
*Steven Harman*
|
563
1008
|
|
1009
|
+
* Deprecate preserving the pre-Ruby 2.4 behavior of `to_time`
|
1010
|
+
|
1011
|
+
With Ruby 2.4+ the default for +to_time+ changed from converting to the
|
1012
|
+
local system time to preserving the offset of the receiver. At the time Rails
|
1013
|
+
supported older versions of Ruby so a compatibility layer was added to assist
|
1014
|
+
in the migration process. From Rails 5.0 new applications have defaulted to
|
1015
|
+
the Ruby 2.4+ behavior and since Rails 7.0 now only supports Ruby 2.7+
|
1016
|
+
this compatibility layer can be safely removed.
|
1017
|
+
|
1018
|
+
To minimize any noise generated the deprecation warning only appears when the
|
1019
|
+
setting is configured to `false` as that is the only scenario where the
|
1020
|
+
removal of the compatibility layer has any effect.
|
1021
|
+
|
1022
|
+
*Andrew White*
|
1023
|
+
|
1024
|
+
* `Pathname.blank?` only returns true for `Pathname.new("")`
|
1025
|
+
|
1026
|
+
Previously it would end up calling `Pathname#empty?` which returned true
|
1027
|
+
if the path existed and was an empty directory or file.
|
1028
|
+
|
1029
|
+
That behavior was unlikely to be expected.
|
1030
|
+
|
1031
|
+
*Jean Boussier*
|
1032
|
+
|
1033
|
+
* Deprecate `Notification::Event`'s `#children` and `#parent_of?`
|
1034
|
+
|
1035
|
+
*John Hawthorn*
|
1036
|
+
|
1037
|
+
* Change the default serializer of `ActiveSupport::MessageVerifier` from
|
1038
|
+
`Marshal` to `ActiveSupport::JSON` when using `config.load_defaults 7.1`.
|
1039
|
+
|
1040
|
+
Messages serialized with `Marshal` can still be read, but new messages will
|
1041
|
+
be serialized with `ActiveSupport::JSON`. For more information, see
|
1042
|
+
https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer.
|
1043
|
+
|
1044
|
+
*Saba Kiaei*, *David Buckley*, and *Jonathan Hefner*
|
1045
|
+
|
1046
|
+
* Change the default serializer of `ActiveSupport::MessageEncryptor` from
|
1047
|
+
`Marshal` to `ActiveSupport::JSON` when using `config.load_defaults 7.1`.
|
1048
|
+
|
1049
|
+
Messages serialized with `Marshal` can still be read, but new messages will
|
1050
|
+
be serialized with `ActiveSupport::JSON`. For more information, see
|
1051
|
+
https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer.
|
1052
|
+
|
1053
|
+
*Zack Deveau*, *Martin Gingras*, and *Jonathan Hefner*
|
1054
|
+
|
1055
|
+
* Add `ActiveSupport::TestCase#stub_const` to stub a constant for the duration of a yield.
|
1056
|
+
|
1057
|
+
*DHH*
|
1058
|
+
|
1059
|
+
* Fix `ActiveSupport::EncryptedConfiguration` to be compatible with Psych 4
|
1060
|
+
|
1061
|
+
*Stephen Sugden*
|
1062
|
+
|
1063
|
+
* Improve `File.atomic_write` error handling
|
1064
|
+
|
1065
|
+
*Daniel Pepper*
|
1066
|
+
|
1067
|
+
* Fix `Class#descendants` and `DescendantsTracker#descendants` compatibility with Ruby 3.1.
|
1068
|
+
|
1069
|
+
[The native `Class#descendants` was reverted prior to Ruby 3.1 release](https://bugs.ruby-lang.org/issues/14394#note-33),
|
1070
|
+
but `Class#subclasses` was kept, breaking the feature detection.
|
1071
|
+
|
1072
|
+
*Jean Boussier*
|
564
1073
|
|
565
|
-
Please check [
|
1074
|
+
Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activesupport/CHANGELOG.md) for previous changes.
|