activesupport 7.1.5 → 7.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +113 -1173
  3. data/lib/active_support/array_inquirer.rb +1 -1
  4. data/lib/active_support/backtrace_cleaner.rb +10 -3
  5. data/lib/active_support/broadcast_logger.rb +18 -19
  6. data/lib/active_support/cache/file_store.rb +15 -10
  7. data/lib/active_support/cache/mem_cache_store.rb +16 -74
  8. data/lib/active_support/cache/memory_store.rb +2 -1
  9. data/lib/active_support/cache/redis_cache_store.rb +16 -13
  10. data/lib/active_support/cache/serializer_with_fallback.rb +0 -23
  11. data/lib/active_support/cache.rb +59 -67
  12. data/lib/active_support/callbacks.rb +74 -113
  13. data/lib/active_support/code_generator.rb +10 -15
  14. data/lib/active_support/core_ext/array/conversions.rb +0 -2
  15. data/lib/active_support/core_ext/class/subclasses.rb +15 -35
  16. data/lib/active_support/core_ext/date/blank.rb +4 -0
  17. data/lib/active_support/core_ext/date/conversions.rb +0 -2
  18. data/lib/active_support/core_ext/date_and_time/compatibility.rb +12 -9
  19. data/lib/active_support/core_ext/date_time/blank.rb +4 -0
  20. data/lib/active_support/core_ext/date_time/compatibility.rb +3 -5
  21. data/lib/active_support/core_ext/date_time/conversions.rb +0 -4
  22. data/lib/active_support/core_ext/erb/util.rb +5 -0
  23. data/lib/active_support/core_ext/hash/keys.rb +4 -4
  24. data/lib/active_support/core_ext/module/attr_internal.rb +17 -6
  25. data/lib/active_support/core_ext/module/delegation.rb +20 -163
  26. data/lib/active_support/core_ext/module/deprecation.rb +1 -4
  27. data/lib/active_support/core_ext/numeric/conversions.rb +3 -3
  28. data/lib/active_support/core_ext/object/blank.rb +45 -1
  29. data/lib/active_support/core_ext/object/instance_variables.rb +11 -19
  30. data/lib/active_support/core_ext/object/json.rb +4 -6
  31. data/lib/active_support/core_ext/object/with.rb +5 -3
  32. data/lib/active_support/core_ext/pathname/blank.rb +4 -0
  33. data/lib/active_support/core_ext/range/overlap.rb +1 -1
  34. data/lib/active_support/core_ext/string/conversions.rb +1 -1
  35. data/lib/active_support/core_ext/string/filters.rb +1 -1
  36. data/lib/active_support/core_ext/string/output_safety.rb +0 -7
  37. data/lib/active_support/core_ext/time/calculations.rb +12 -27
  38. data/lib/active_support/core_ext/time/compatibility.rb +2 -3
  39. data/lib/active_support/core_ext/time/conversions.rb +0 -2
  40. data/lib/active_support/core_ext.rb +0 -1
  41. data/lib/active_support/current_attributes.rb +33 -40
  42. data/lib/active_support/delegation.rb +188 -0
  43. data/lib/active_support/dependencies/autoload.rb +0 -12
  44. data/lib/active_support/deprecation/constant_accessor.rb +1 -3
  45. data/lib/active_support/deprecation/proxy_wrappers.rb +9 -12
  46. data/lib/active_support/deprecation/reporting.rb +9 -4
  47. data/lib/active_support/deprecation.rb +8 -5
  48. data/lib/active_support/descendants_tracker.rb +9 -87
  49. data/lib/active_support/duration/iso8601_parser.rb +2 -2
  50. data/lib/active_support/duration/iso8601_serializer.rb +1 -2
  51. data/lib/active_support/duration.rb +11 -6
  52. data/lib/active_support/error_reporter.rb +41 -3
  53. data/lib/active_support/evented_file_update_checker.rb +0 -1
  54. data/lib/active_support/execution_wrapper.rb +0 -1
  55. data/lib/active_support/file_update_checker.rb +1 -1
  56. data/lib/active_support/fork_tracker.rb +2 -38
  57. data/lib/active_support/gem_version.rb +3 -3
  58. data/lib/active_support/hash_with_indifferent_access.rb +6 -8
  59. data/lib/active_support/html_safe_translation.rb +3 -0
  60. data/lib/active_support/log_subscriber.rb +0 -12
  61. data/lib/active_support/logger.rb +15 -2
  62. data/lib/active_support/message_pack/extensions.rb +15 -2
  63. data/lib/active_support/multibyte/chars.rb +2 -2
  64. data/lib/active_support/notifications/fanout.rb +4 -7
  65. data/lib/active_support/notifications/instrumenter.rb +21 -18
  66. data/lib/active_support/notifications.rb +28 -27
  67. data/lib/active_support/number_helper/number_converter.rb +2 -2
  68. data/lib/active_support/option_merger.rb +2 -2
  69. data/lib/active_support/ordered_options.rb +53 -15
  70. data/lib/active_support/proxy_object.rb +8 -5
  71. data/lib/active_support/railtie.rb +4 -11
  72. data/lib/active_support/string_inquirer.rb +1 -1
  73. data/lib/active_support/syntax_error_proxy.rb +11 -1
  74. data/lib/active_support/test_case.rb +3 -1
  75. data/lib/active_support/testing/assertions.rb +4 -4
  76. data/lib/active_support/testing/constant_stubbing.rb +30 -8
  77. data/lib/active_support/testing/deprecation.rb +5 -12
  78. data/lib/active_support/testing/isolation.rb +18 -8
  79. data/lib/active_support/testing/method_call_assertions.rb +2 -16
  80. data/lib/active_support/testing/strict_warnings.rb +5 -4
  81. data/lib/active_support/testing/tests_without_assertions.rb +19 -0
  82. data/lib/active_support/time_with_zone.rb +9 -10
  83. data/lib/active_support/values/time_zone.rb +1 -1
  84. data/lib/active_support/xml_mini.rb +11 -2
  85. data/lib/active_support.rb +7 -8
  86. metadata +20 -70
  87. data/lib/active_support/deprecation/instance_delegator.rb +0 -65
  88. data/lib/active_support/ruby_features.rb +0 -7
data/CHANGELOG.md CHANGED
@@ -1,1296 +1,236 @@
1
- ## Rails 7.1.5 (October 30, 2024) ##
1
+ ## Rails 7.2.0.beta1 (May 29, 2024) ##
2
2
 
3
- * No changes.
3
+ * Support `duration` type in `ActiveSupport::XmlMini`.
4
4
 
5
+ *heka1024*
5
6
 
6
- ## Rails 7.1.4.2 (October 23, 2024) ##
7
+ * Remove deprecated `ActiveSupport::Notifications::Event#children` and `ActiveSupport::Notifications::Event#parent_of?`.
7
8
 
8
- * No changes.
9
-
10
-
11
- ## Rails 7.1.4.1 (October 15, 2024) ##
12
-
13
- * No changes.
14
-
15
-
16
- ## Rails 7.1.4 (August 22, 2024) ##
17
-
18
- * Improve compatibility for `ActiveSupport::BroadcastLogger`.
19
-
20
- *Máximo Mussini*
21
-
22
- * Pass options along to write_entry in handle_expired_entry method.
23
-
24
- *Graham Cooper*
25
-
26
- * Fix Active Support configurations deprecations.
27
-
28
- *fatkodima*
29
-
30
- * Fix teardown callbacks.
31
-
32
- *Tristan Starck*
33
-
34
- * `BacktraceCleaner` silence core internal methods by default.
35
-
36
- *Jean Boussier*
37
-
38
- * Fix `delegate_missing_to allow_nil: true` when called with implict self
39
-
40
- ```ruby
41
- class Person
42
- delegate_missing_to :address, allow_nil: true
43
-
44
- def address
45
- nil
46
- end
47
-
48
- def berliner?
49
- city == "Berlin"
50
- end
51
- end
52
-
53
- Person.new.city # => nil
54
- Person.new.berliner? # undefined local variable or method `city' for an instance of Person (NameError)
55
- ```
56
-
57
- *Jean Boussier*
58
-
59
- * Work around a Ruby bug that can cause a VM crash.
60
-
61
- This would happen if using `TaggerLogger` with a Proc
62
- formatter on which you called `object_id`.
63
-
64
- ```
65
- [BUG] Object ID seen, but not in mapping table: proc
66
- ```
67
-
68
- *Jean Boussier*
69
-
70
- * Fix `ActiveSupport::Notifications.publish_event` to preserve units.
71
-
72
- This solves the incorrect reporting of time spent running Active Record
73
- asynchronous queries (by a factor `1000`).
74
-
75
- *Jean Boussier*
76
-
77
-
78
- ## Rails 7.1.3.4 (June 04, 2024) ##
79
-
80
- * No changes.
81
-
82
-
83
- ## Rails 7.1.3.3 (May 16, 2024) ##
84
-
85
- * No changes.
86
-
87
-
88
- ## Rails 7.1.3.2 (February 21, 2024) ##
89
-
90
- * No changes.
91
-
92
-
93
- ## Rails 7.1.3.1 (February 21, 2024) ##
94
-
95
- * No changes.
96
-
97
-
98
- ## Rails 7.1.3 (January 16, 2024) ##
99
-
100
- * Handle nil `backtrace_locations` in `ActiveSupport::SyntaxErrorProxy`.
101
-
102
- *Eugene Kenny*
103
-
104
- * Fix `ActiveSupport::JSON.encode` to prevent duplicate keys.
105
-
106
- If the same key exist in both String and Symbol form it could
107
- lead to the same key being emitted twice.
108
-
109
- *Manish Sharma*
110
-
111
- * Fix `ActiveSupport::Cache::Store#read_multi` when using a cache namespace
112
- and local cache strategy.
113
-
114
- *Mark Oleson*
115
-
116
- * Fix `Time.now/DateTime.now/Date.today` to return results in a system timezone after `#travel_to`.
117
-
118
- There is a bug in the current implementation of #travel_to:
119
- it remembers a timezone of its argument, and all stubbed methods start
120
- returning results in that remembered timezone. However, the expected
121
- behaviour is to return results in a system timezone.
122
-
123
- *Aleksei Chernenkov*
124
-
125
- * Fix `:unless_exist` option for `MemoryStore#write` (et al) when using a
126
- cache namespace.
127
-
128
- *S. Brent Faulkner*
129
-
130
- * Fix ActiveSupport::Deprecation to handle blaming generated code.
131
-
132
- *Jean Boussier*, *fatkodima*
133
-
134
-
135
- ## Rails 7.1.2 (November 10, 2023) ##
136
-
137
- * Fix `:expires_in` option for `RedisCacheStore#write_multi`.
138
-
139
- *fatkodima*
140
-
141
- * Fix deserialization of non-string "purpose" field in Message serializer
142
-
143
- *Jacopo Beschi*
144
-
145
- * Prevent global cache options being overwritten when setting dynamic options
146
- inside a `ActiveSupport::Cache::Store#fetch` block.
147
-
148
- *Yasha Krasnou*
149
-
150
- * Fix missing `require` resulting in `NoMethodError` when running
151
- `bin/rails secrets:show` or `bin/rails secrets:edit`.
152
-
153
- *Stephen Ierodiaconou*
154
-
155
- * Ensure `{down,up}case_first` returns non-frozen string.
156
-
157
- *Jonathan Hefner*
158
-
159
- * Fix `#to_fs(:human_size)` to correctly work with negative numbers.
160
-
161
- *Earlopain*
162
-
163
- * Fix `BroadcastLogger#dup` so that it duplicates the logger's `broadcasts`.
164
-
165
- *Andrew Novoselac*
166
-
167
- * Fix issue where `bootstrap.rb` overwrites the `level` of a `BroadcastLogger`'s `broadcasts`.
168
-
169
- *Andrew Novoselac*
170
-
171
- * Fix `ActiveSupport::Cache` to handle outdated Marshal payload from Rails 6.1 format.
172
-
173
- Active Support's Cache is supposed to treat a Marshal payload that can no longer be
174
- deserialized as a cache miss. It fail to do so for compressed payload in the Rails 6.1
175
- legacy format.
176
-
177
- *Jean Boussier*
178
-
179
- * Fix `OrderedOptions#dig` for array indexes.
180
-
181
- *fatkodima*
182
-
183
- * Fix time travel helpers to work when nested using with separate classes.
184
-
185
- *fatkodima*
186
-
187
- * Fix `delete_matched` for file cache store to work with keys longer than the
188
- max filename size.
189
-
190
- *fatkodima* and *Jonathan Hefner*
191
-
192
- * Fix compatibility with the `semantic_logger` gem.
193
-
194
- The `semantic_logger` gem doesn't behave exactly like stdlib logger in that
195
- `SemanticLogger#level` returns a Symbol while stdlib `Logger#level` returns an Integer.
196
-
197
- This caused the various `LogSubscriber` classes in Rails to break when assigned a
198
- `SemanticLogger` instance.
199
-
200
- *Jean Boussier*, *ojab*
201
-
202
- ## Rails 7.1.1 (October 11, 2023) ##
203
-
204
- * Add support for keyword arguments when delegating calls to custom loggers from `ActiveSupport::BroadcastLogger`.
205
-
206
- *Edouard Chin*
207
-
208
- * `NumberHelper`: handle objects responding `to_d`.
209
-
210
- *fatkodima*
211
-
212
- * Fix RedisCacheStore to properly set the TTL when incrementing or decrementing.
213
-
214
- This bug was only impacting Redis server older than 7.0.
215
-
216
- *Thomas Countz*
217
-
218
- * Fix MemoryStore to prevent race conditions when incrementing or decrementing.
219
-
220
- *Pierre Jambet*
221
-
222
-
223
- ## Rails 7.1.0 (October 05, 2023) ##
224
-
225
- * No changes.
226
-
227
-
228
- ## Rails 7.1.0.rc2 (October 01, 2023) ##
229
-
230
- * Fix `AS::MessagePack` with `ENV["RAILS_MAX_THREADS"]`.
231
-
232
- *Jonathan Hefner*
233
-
234
-
235
- ## Rails 7.1.0.rc1 (September 27, 2023) ##
236
-
237
- * Add a new public API for broadcasting logs
238
-
239
- This feature existed for a while but was until now a private API.
240
- Broadcasting log allows to send log message to difference sinks (STDOUT, a file ...) and
241
- is used by default in the development environment to write logs both on STDOUT and in the
242
- "development.log" file.
243
-
244
- Basic usage:
245
-
246
- ```ruby
247
- stdout_logger = Logger.new(STDOUT)
248
- file_logger = Logger.new("development.log")
249
- broadcast = ActiveSupport::BroadcastLogger.new(stdout_logger, file_logger)
250
-
251
- broadcast.info("Hello!") # The "Hello!" message is written on STDOUT and in the log file.
252
- ```
253
-
254
- Adding other sink(s) to the broadcast:
255
-
256
- ```ruby
257
- broadcast = ActiveSupport::BroadcastLogger.new
258
- broadcast.broadcast_to(Logger.new(STDERR))
259
- ```
260
-
261
- Remove a sink from the broadcast:
262
-
263
- ```ruby
264
- stdout_logger = Logger.new(STDOUT)
265
- broadcast = ActiveSupport::BroadcastLogger.new(stdout_logger)
266
-
267
- broadcast.stop_broadcasting_to(stdout_logger)
268
- ```
269
-
270
- *Edouard Chin*
271
-
272
- * Fix Range#overlap? not taking empty ranges into account on Ruby < 3.3
273
-
274
- *Nobuyoshi Nakada*, *Shouichi Kamiya*, *Hartley McGuire*
275
-
276
- * Use Ruby 3.3 Range#overlap? if available
277
-
278
- *Yasuo Honda*
279
-
280
-
281
- ## Rails 7.1.0.beta1 (September 13, 2023) ##
282
-
283
- * Add `bigdecimal` as Active Support dependency that is a bundled gem candidate for Ruby 3.4.
284
-
285
- `bigdecimal` 3.1.4 or higher version will be installed.
286
- Ruby 2.7 and 3.0 users who want `bigdecimal` version 2.0.0 or 3.0.0 behavior as a default gem,
287
- pin the `bigdecimal` version in your application Gemfile.
288
-
289
- *Koichi ITO*
290
-
291
- * Add `drb`, `mutex_m` and `base64` that are bundled gem candidates for Ruby 3.4
292
-
293
- *Yasuo Honda*
294
-
295
- * When using cache format version >= 7.1 or a custom serializer, expired and
296
- version-mismatched cache entries can now be detected without deserializing
297
- their values.
298
-
299
- *Jonathan Hefner*
300
-
301
- * Make all cache stores return a boolean for `#delete`
302
-
303
- Previously the `RedisCacheStore#delete` would return `1` if the entry
304
- exists and `0` otherwise. Now it returns true if the entry exists and false
305
- otherwise, just like the other stores.
306
-
307
- The `FileStore` would return `nil` if the entry doesn't exists and returns
308
- `false` now as well.
309
-
310
- *Petrik de Heus*
311
-
312
- * Active Support cache stores now support replacing the default compressor via
313
- a `:compressor` option. The specified compressor must respond to `deflate`
314
- and `inflate`. For example:
315
-
316
- ```ruby
317
- module MyCompressor
318
- def self.deflate(string)
319
- # compression logic...
320
- end
321
-
322
- def self.inflate(compressed)
323
- # decompression logic...
324
- end
325
- end
326
-
327
- config.cache_store = :redis_cache_store, { compressor: MyCompressor }
328
- ```
329
-
330
- *Jonathan Hefner*
331
-
332
- * Active Support cache stores now support a `:serializer` option. Similar to
333
- the `:coder` option, serializers must respond to `dump` and `load`. However,
334
- serializers are only responsible for serializing a cached value, whereas
335
- coders are responsible for serializing the entire `ActiveSupport::Cache::Entry`
336
- instance. Additionally, the output from serializers can be automatically
337
- compressed, whereas coders are responsible for their own compression.
338
-
339
- Specifying a serializer instead of a coder also enables performance
340
- optimizations, including the bare string optimization introduced by cache
341
- format version 7.1.
342
-
343
- The `:serializer` and `:coder` options are mutually exclusive. Specifying
344
- both will raise an `ArgumentError`.
345
-
346
- *Jonathan Hefner*
347
-
348
- * Fix `ActiveSupport::Inflector.humanize(nil)` raising ``NoMethodError: undefined method `end_with?' for nil:NilClass``.
349
-
350
- *James Robinson*
351
-
352
- * Don't show secrets for `ActiveSupport::KeyGenerator#inspect`.
353
-
354
- Before:
355
-
356
- ```ruby
357
- ActiveSupport::KeyGenerator.new(secret).inspect
358
- "#<ActiveSupport::KeyGenerator:0x0000000104888038 ... @secret=\"\\xAF\\bFh]LV}q\\nl\\xB2U\\xB3 ... >"
359
- ```
360
-
361
- After:
362
-
363
- ```ruby
364
- ActiveSupport::KeyGenerator::Aes256Gcm(secret).inspect
365
- "#<ActiveSupport::KeyGenerator:0x0000000104888038>"
366
- ```
367
-
368
- *Petrik de Heus*
369
-
370
- * Improve error message when EventedFileUpdateChecker is used without a
371
- compatible version of the Listen gem
372
-
373
- *Hartley McGuire*
374
-
375
- * Add `:report` behavior for Deprecation
376
-
377
- Setting `config.active_support.deprecation = :report` uses the error
378
- reporter to report deprecation warnings to `ActiveSupport::ErrorReporter`.
379
-
380
- Deprecations are reported as handled errors, with a severity of `:warning`.
381
-
382
- Useful to report deprecations happening in production to your bug tracker.
383
-
384
- *Étienne Barrié*
385
-
386
- * Rename `Range#overlaps?` to `#overlap?` and add alias for backwards compatibility
387
-
388
- *Christian Schmidt*
389
-
390
- * Fix `EncryptedConfiguration` returning incorrect values for some `Hash`
391
- methods
392
-
393
- *Hartley McGuire*
394
-
395
- * Don't show secrets for `MessageEncryptor#inspect`.
396
-
397
- Before:
398
-
399
- ```ruby
400
- ActiveSupport::MessageEncryptor.new(secret, cipher: "aes-256-gcm").inspect
401
- "#<ActiveSupport::MessageEncryptor:0x0000000104888038 ... @secret=\"\\xAF\\bFh]LV}q\\nl\\xB2U\\xB3 ... >"
402
- ```
403
-
404
- After:
405
-
406
- ```ruby
407
- ActiveSupport::MessageEncryptor.new(secret, cipher: "aes-256-gcm").inspect
408
- "#<ActiveSupport::MessageEncryptor:0x0000000104888038>"
409
- ```
410
-
411
- *Petrik de Heus*
412
-
413
- * Don't show contents for `EncryptedConfiguration#inspect`.
414
-
415
- Before:
416
- ```ruby
417
- Rails.application.credentials.inspect
418
- "#<ActiveSupport::EncryptedConfiguration:0x000000010d2b38e8 ... @config={:secret=>\"something secret\"} ... @key_file_contents=\"915e4ea054e011022398dc242\" ...>"
419
- ```
420
-
421
- After:
422
- ```ruby
423
- Rails.application.credentials.inspect
424
- "#<ActiveSupport::EncryptedConfiguration:0x000000010d2b38e8>"
425
- ```
426
-
427
- *Petrik de Heus*
428
-
429
- * `ERB::Util.html_escape_once` always returns an `html_safe` string.
430
-
431
- This method previously maintained the `html_safe?` property of a string on the return
432
- value. Because this string has been escaped, however, not marking it as `html_safe` causes
433
- entities to be double-escaped.
434
-
435
- As an example, take this view snippet:
436
-
437
- ```html
438
- <p><%= html_escape_once("this & that &amp; the other") %></p>
439
- ```
440
-
441
- Before this change, that would be double-escaped and render as:
442
-
443
- ```html
444
- <p>this &amp;amp; that &amp;amp; the other</p>
445
- ```
446
-
447
- After this change, it renders correctly as:
448
-
449
- ```html
450
- <p>this &amp; that &amp; the other</p>
451
- ```
452
-
453
- Fixes #48256
454
-
455
- *Mike Dalessio*
456
-
457
- * Deprecate `SafeBuffer#clone_empty`.
458
-
459
- This method has not been used internally since Rails 4.2.0.
460
-
461
- *Mike Dalessio*
462
-
463
- * `MessageEncryptor`, `MessageVerifier`, and `config.active_support.message_serializer`
464
- now accept `:message_pack` and `:message_pack_allow_marshal` as serializers.
465
- These serializers require the [`msgpack` gem](https://rubygems.org/gems/msgpack)
466
- (>= 1.7.0).
467
-
468
- The Message Pack format can provide improved performance and smaller payload
469
- sizes. It also supports round-tripping some Ruby types that are not supported
470
- by JSON. For example:
471
-
472
- ```ruby
473
- verifier = ActiveSupport::MessageVerifier.new("secret")
474
- data = [{ a: 1 }, { b: 2 }.with_indifferent_access, 1.to_d, Time.at(0, 123)]
475
- message = verifier.generate(data)
476
-
477
- # BEFORE with config.active_support.message_serializer = :json
478
- verifier.verified(message)
479
- # => [{"a"=>1}, {"b"=>2}, "1.0", "1969-12-31T18:00:00.000-06:00"]
480
- verifier.verified(message).map(&:class)
481
- # => [Hash, Hash, String, String]
482
-
483
- # AFTER with config.active_support.message_serializer = :message_pack
484
- verifier.verified(message)
485
- # => [{:a=>1}, {"b"=>2}, 0.1e1, 1969-12-31 18:00:00.000123 -0600]
486
- verifier.verified(message).map(&:class)
487
- # => [Hash, ActiveSupport::HashWithIndifferentAccess, BigDecimal, Time]
488
- ```
489
-
490
- The `:message_pack` serializer can fall back to deserializing with
491
- `ActiveSupport::JSON` when necessary, and the `:message_pack_allow_marshal`
492
- serializer can fall back to deserializing with `Marshal` as well as
493
- `ActiveSupport::JSON`. Additionally, the `:marshal`, `:json`, and
494
- `:json_allow_marshal` serializers can now fall back to deserializing with
495
- `ActiveSupport::MessagePack` when necessary. These behaviors ensure old
496
- messages can still be read so that migration is easier.
497
-
498
- *Jonathan Hefner*
499
-
500
- * A new `7.1` cache format is available which includes an optimization for
501
- bare string values such as view fragments.
502
-
503
- The `7.1` cache format is used by default for new apps, and existing apps
504
- can enable the format by setting `config.load_defaults 7.1` or by setting
505
- `config.active_support.cache_format_version = 7.1` in `config/application.rb`
506
- or a `config/environments/*.rb` file.
507
-
508
- Cache entries written using the `6.1` or `7.0` cache formats can be read
509
- when using the `7.1` format. To perform a rolling deploy of a Rails 7.1
510
- upgrade, wherein servers that have not yet been upgraded must be able to
511
- read caches from upgraded servers, leave the cache format unchanged on the
512
- first deploy, then enable the `7.1` cache format on a subsequent deploy.
513
-
514
- *Jonathan Hefner*
515
-
516
- * Active Support cache stores can now use a preconfigured serializer based on
517
- `ActiveSupport::MessagePack` via the `:serializer` option:
518
-
519
- ```ruby
520
- config.cache_store = :redis_cache_store, { serializer: :message_pack }
521
- ```
522
-
523
- The `:message_pack` serializer can reduce cache entry sizes and improve
524
- performance, but requires the [`msgpack` gem](https://rubygems.org/gems/msgpack)
525
- (>= 1.7.0).
526
-
527
- The `:message_pack` serializer can read cache entries written by the default
528
- serializer, and the default serializer can now read entries written by the
529
- `:message_pack` serializer. These behaviors make it easy to migrate between
530
- serializer without invalidating the entire cache.
531
-
532
- *Jonathan Hefner*
533
-
534
- * `Object#deep_dup` no longer duplicate named classes and modules.
535
-
536
- Before:
537
-
538
- ```ruby
539
- hash = { class: Object, module: Kernel }
540
- hash.deep_dup # => {:class=>#<Class:0x00000001063ffc80>, :module=>#<Module:0x00000001063ffa00>}
541
- ```
542
-
543
- After:
544
-
545
- ```ruby
546
- hash = { class: Object, module: Kernel }
547
- hash.deep_dup # => {:class=>Object, :module=>Kernel}
548
- ```
549
-
550
- *Jean Boussier*
551
-
552
- * Consistently raise an `ArgumentError` if the `ActiveSupport::Cache` key is blank.
553
-
554
- *Joshua Young*
555
-
556
- * Deprecate usage of the singleton `ActiveSupport::Deprecation`.
557
-
558
- All usage of `ActiveSupport::Deprecation` as a singleton is deprecated, the most common one being
559
- `ActiveSupport::Deprecation.warn`. Gem authors should now create their own deprecator (`ActiveSupport::Deprecation`
560
- object), and use it to emit deprecation warnings.
561
-
562
- Calling any of the following without specifying a deprecator argument is also deprecated:
563
- * Module.deprecate
564
- * deprecate_constant
565
- * DeprecatedObjectProxy
566
- * DeprecatedInstanceVariableProxy
567
- * DeprecatedConstantProxy
568
- * deprecation-related test assertions
569
-
570
- Use of `ActiveSupport::Deprecation.silence` and configuration methods like `behavior=`, `disallowed_behavior=`,
571
- `disallowed_warnings=` should now be aimed at the [application's deprecators](https://api.rubyonrails.org/classes/Rails/Application.html#method-i-deprecators).
572
-
573
- ```ruby
574
- Rails.application.deprecators.silence do
575
- # code that emits deprecation warnings
576
- end
577
- ```
578
-
579
- If your gem has a Railtie or Engine, it's encouraged to add your deprecator to the application's deprecators, that
580
- way the deprecation related configuration options will apply to it as well, e.g.
581
- `config.active_support.report_deprecations` set to `false` in the production environment will also disable your
582
- deprecator.
583
-
584
- ```ruby
585
- initializer "my_gem.deprecator" do |app|
586
- app.deprecators[:my_gem] = MyGem.deprecator
587
- end
588
- ```
589
-
590
- *Étienne Barrié*
9
+ *Rafael Mendonça França*
591
10
 
592
- * Add `Object#with` to set and restore public attributes around a block
11
+ * Remove deprecated support to call the following methods without passing a deprecator:
593
12
 
594
- ```ruby
595
- client.timeout # => 5
596
- client.with(timeout: 1) do
597
- client.timeout # => 1
598
- end
599
- client.timeout # => 5
600
- ```
13
+ - `deprecate`
14
+ - `deprecate_constant`
15
+ - `ActiveSupport::Deprecation::DeprecatedObjectProxy.new`
16
+ - `ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new`
17
+ - `ActiveSupport::Deprecation::DeprecatedConstantProxy.new`
18
+ - `assert_deprecated`
19
+ - `assert_not_deprecated`
20
+ - `collect_deprecations`
601
21
 
602
- *Jean Boussier*
22
+ *Rafael Mendonça França*
603
23
 
604
- * Remove deprecated support to generate incorrect RFC 4122 UUIDs when providing a namespace ID that is not one of the
605
- constants defined on `Digest::UUID`.
24
+ * Remove deprecated `ActiveSupport::Deprecation` delegation to instance.
606
25
 
607
26
  *Rafael Mendonça França*
608
27
 
609
- * Deprecate `config.active_support.use_rfc4122_namespaced_uuids`.
28
+ * Remove deprecated `SafeBuffer#clone_empty`.
610
29
 
611
30
  *Rafael Mendonça França*
612
31
 
613
- * Remove implicit conversion of objects into `String` by `ActiveSupport::SafeBuffer`.
32
+ * Remove deprecated `#to_default_s` from `Array`, `Date`, `DateTime` and `Time`.
614
33
 
615
34
  *Rafael Mendonça França*
616
35
 
617
- * Remove deprecated `active_support/core_ext/range/include_time_with_zone` file.
36
+ * Remove deprecated support to passing `Dalli::Client` instances to `MemCacheStore`.
618
37
 
619
38
  *Rafael Mendonça França*
620
39
 
621
- * Deprecate `config.active_support.remove_deprecated_time_with_zone_name`.
40
+ * Remove deprecated `config.active_support.use_rfc4122_namespaced_uuids`.
622
41
 
623
42
  *Rafael Mendonça França*
624
43
 
625
- * Remove deprecated override of `ActiveSupport::TimeWithZone.name`.
44
+ * Remove deprecated `config.active_support.remove_deprecated_time_with_zone_name`.
626
45
 
627
46
  *Rafael Mendonça França*
628
47
 
629
- * Deprecate `config.active_support.disable_to_s_conversion`.
48
+ * Remove deprecated `config.active_support.disable_to_s_conversion`.
630
49
 
631
50
  *Rafael Mendonça França*
632
51
 
633
- * Remove deprecated option to passing a format to `#to_s` in `Array`, `Range`, `Date`, `DateTime`, `Time`,
634
- `BigDecimal`, `Float` and, `Integer`.
52
+ * Remove deprecated support to bolding log text with positional boolean in `ActiveSupport::LogSubscriber#color`.
635
53
 
636
54
  *Rafael Mendonça França*
637
55
 
638
- * Remove deprecated `ActiveSupport::PerThreadRegistry`.
56
+ * Remove deprecated constants `ActiveSupport::LogSubscriber::CLEAR` and `ActiveSupport::LogSubscriber::BOLD`.
639
57
 
640
58
  *Rafael Mendonça França*
641
59
 
642
- * Remove deprecated override of `Enumerable#sum`.
60
+ * Remove deprecated support for `config.active_support.cache_format_version = 6.1`.
643
61
 
644
62
  *Rafael Mendonça França*
645
63
 
646
- * Deprecated initializing a `ActiveSupport::Cache::MemCacheStore` with an instance of `Dalli::Client`.
647
-
648
- 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.
64
+ * Remove deprecated `:pool_size` and `:pool_timeout` options for the cache storage.
649
65
 
650
- *aledustet*
66
+ *Rafael Mendonça França*
651
67
 
652
- * Stub `Time.new()` in `TimeHelpers#travel_to`
68
+ * Warn on tests without assertions.
653
69
 
654
- ```ruby
655
- travel_to Time.new(2004, 11, 24) do
656
- # Inside the `travel_to` block `Time.new` is stubbed
657
- assert_equal 2004, Time.new.year
658
- end
659
- ```
70
+ `ActiveSupport::TestCase` now warns when tests do not run any assertions.
71
+ This is helpful in detecting broken tests that do not perform intended assertions.
660
72
 
661
73
  *fatkodima*
662
74
 
663
- * Raise `ActiveSupport::MessageEncryptor::InvalidMessage` from
664
- `ActiveSupport::MessageEncryptor#decrypt_and_verify` regardless of cipher.
665
- Previously, when a `MessageEncryptor` was using a non-AEAD cipher such as
666
- AES-256-CBC, a corrupt or tampered message would raise
667
- `ActiveSupport::MessageVerifier::InvalidSignature`. Now, all ciphers raise
668
- the same error:
669
-
670
- ```ruby
671
- encryptor = ActiveSupport::MessageEncryptor.new("x" * 32, cipher: "aes-256-gcm")
672
- message = encryptor.encrypt_and_sign("message")
673
- encryptor.decrypt_and_verify(message.next)
674
- # => raises ActiveSupport::MessageEncryptor::InvalidMessage
675
-
676
- encryptor = ActiveSupport::MessageEncryptor.new("x" * 32, cipher: "aes-256-cbc")
677
- message = encryptor.encrypt_and_sign("message")
678
- encryptor.decrypt_and_verify(message.next)
679
- # BEFORE:
680
- # => raises ActiveSupport::MessageVerifier::InvalidSignature
681
- # AFTER:
682
- # => raises ActiveSupport::MessageEncryptor::InvalidMessage
683
- ```
684
-
685
- *Jonathan Hefner*
686
-
687
- * Support `nil` original values when using `ActiveSupport::MessageVerifier#verify`.
688
- Previously, `MessageVerifier#verify` did not work with `nil` original
689
- values, though both `MessageVerifier#verified` and
690
- `MessageEncryptor#decrypt_and_verify` do:
691
-
692
- ```ruby
693
- encryptor = ActiveSupport::MessageEncryptor.new(secret)
694
- message = encryptor.encrypt_and_sign(nil)
695
-
696
- encryptor.decrypt_and_verify(message)
697
- # => nil
698
-
699
- verifier = ActiveSupport::MessageVerifier.new(secret)
700
- message = verifier.generate(nil)
701
-
702
- verifier.verified(message)
703
- # => nil
704
-
705
- verifier.verify(message)
706
- # BEFORE:
707
- # => raises ActiveSupport::MessageVerifier::InvalidSignature
708
- # AFTER:
709
- # => nil
710
- ```
711
-
712
- *Jonathan Hefner*
713
-
714
- * Maintain `html_safe?` on html_safe strings when sliced with `slice`, `slice!`, or `chr` method.
715
-
716
- Previously, `html_safe?` was only maintained when the html_safe strings were sliced
717
- with `[]` method. Now, `slice`, `slice!`, and `chr` methods will maintain `html_safe?` like `[]` method.
718
-
719
- ```ruby
720
- string = "<div>test</div>".html_safe
721
- string.slice(0, 1).html_safe? # => true
722
- string.slice!(0, 1).html_safe? # => true
723
- # maintain html_safe? after the slice!
724
- string.html_safe? # => true
725
- string.chr.html_safe? # => true
726
- ```
727
-
728
- *Michael Go*
729
-
730
- * Add `Object#in?` support for open ranges.
731
-
732
- ```ruby
733
- assert Date.today.in?(..Date.tomorrow)
734
- assert_not Date.today.in?(Date.tomorrow..)
735
- ```
736
-
737
- *Ignacio Galindo*
738
-
739
- * `config.i18n.raise_on_missing_translations = true` now raises on any missing translation.
740
-
741
- Previously it would only raise when called in a view or controller. Now it will raise
742
- anytime `I18n.t` is provided an unrecognised key.
743
-
744
- If you do not want this behaviour, you can customise the i18n exception handler. See the
745
- upgrading guide or i18n guide for more information.
746
-
747
- *Alex Ghiculescu*
748
-
749
- * `ActiveSupport::CurrentAttributes` now raises if a restricted attribute name is used.
750
-
751
- Attributes such as `set` and `reset` cannot be used as they clash with the
752
- `CurrentAttributes` public API.
753
-
754
- *Alex Ghiculescu*
755
-
756
- * `HashWithIndifferentAccess#transform_keys` now takes a Hash argument, just
757
- as Ruby's `Hash#transform_keys` does.
75
+ * Support `hexBinary` type in `ActiveSupport::XmlMini`.
758
76
 
759
- *Akira Matsuda*
77
+ *heka1024*
760
78
 
761
- * `delegate` now defines method with proper arity when delegating to a Class.
762
- With this change, it defines faster method (3.5x faster with no argument).
763
- However, in order to gain this benefit, the delegation target method has to
764
- be defined before declaring the delegation.
79
+ * Deprecate `ActiveSupport::ProxyObject` in favor of Ruby's built-in `BasicObject`.
765
80
 
766
- ```ruby
767
- # This defines 3.5 times faster method than before
768
- class C
769
- def self.x() end
770
- delegate :x, to: :class
771
- end
772
-
773
- class C
774
- # This works but silently falls back to old behavior because
775
- # `delegate` cannot find the definition of `x`
776
- delegate :x, to: :class
777
- def self.x() end
778
- end
779
- ```
780
-
781
- *Akira Matsuda*
81
+ *Earlopain*
782
82
 
783
- * `assert_difference` message now includes what changed.
83
+ * `stub_const` now accepts a `exists: false` parameter to allow stubbing missing constants.
784
84
 
785
- This makes it easier to debug non-obvious failures.
85
+ *Jean Boussier*
786
86
 
787
- Before:
87
+ * Make `ActiveSupport::BacktraceCleaner` copy filters and silencers on dup and clone.
788
88
 
789
- ```
790
- "User.count" didn't change by 32.
791
- Expected: 1611
792
- Actual: 1579
793
- ```
89
+ Previously the copy would still share the internal silencers and filters array,
90
+ causing state to leak.
794
91
 
795
- After:
92
+ *Jean Boussier*
796
93
 
797
- ```
798
- "User.count" didn't change by 32, but by 0.
799
- Expected: 1611
800
- Actual: 1579
801
- ```
94
+ * Updating Astana with Western Kazakhstan TZInfo identifier.
802
95
 
803
- *Alex Ghiculescu*
96
+ *Damian Nelson*
804
97
 
805
- * Add ability to match exception messages to `assert_raises` assertion
98
+ * Add filename support for `ActiveSupport::Logger.logger_outputs_to?`.
806
99
 
807
- Instead of this
808
100
  ```ruby
809
- error = assert_raises(ArgumentError) do
810
- perform_service(param: 'exception')
811
- end
812
- assert_match(/incorrect param/i, error.message)
101
+ logger = Logger.new('/var/log/rails.log')
102
+ ActiveSupport::Logger.logger_outputs_to?(logger, '/var/log/rails.log')
813
103
  ```
814
104
 
815
- you can now write this
816
- ```ruby
817
- assert_raises(ArgumentError, match: /incorrect param/i) do
818
- perform_service(param: 'exception')
819
- end
820
- ```
821
-
822
- *fatkodima*
823
-
824
- * Add `Rails.env.local?` shorthand for `Rails.env.development? || Rails.env.test?`.
825
-
826
- *DHH*
105
+ *Christian Schmidt*
827
106
 
828
- * `ActiveSupport::Testing::TimeHelpers` now accepts named `with_usec` argument
829
- to `freeze_time`, `travel`, and `travel_to` methods. Passing true prevents
830
- truncating the destination time with `change(usec: 0)`.
107
+ * Include `IPAddr#prefix` when serializing an `IPAddr` using the
108
+ `ActiveSupport::MessagePack` serializer.
831
109
 
832
- *KevSlashNull*, and *serprex*
110
+ This change is backward and forward compatible — old payloads can
111
+ still be read, and new payloads will be readable by older versions of Rails.
833
112
 
834
- * `ActiveSupport::CurrentAttributes.resets` now accepts a method name
113
+ *Taiki Komaba*
835
114
 
836
- The block API is still the recommended approach, but now both APIs are supported:
115
+ * Add `default:` support for `ActiveSupport::CurrentAttributes.attribute`.
837
116
 
838
117
  ```ruby
839
118
  class Current < ActiveSupport::CurrentAttributes
840
- resets { Time.zone = nil }
841
- resets :clear_time_zone
119
+ attribute :counter, default: 0
842
120
  end
843
121
  ```
844
122
 
845
- *Alex Ghiculescu*
846
-
847
- * Ensure `ActiveSupport::Testing::Isolation::Forking` closes pipes
848
-
849
- Previously, `Forking.run_in_isolation` opened two ends of a pipe. The fork
850
- process closed the read end, wrote to it, and then terminated (which
851
- presumably closed the file descriptors on its end). The parent process
852
- closed the write end, read from it, and returned, never closing the read
853
- end.
123
+ *Sean Doyle*
854
124
 
855
- This resulted in an accumulation of open file descriptors, which could
856
- cause errors if the limit is reached.
125
+ * Remove deprecated support for the pre-Ruby 2.4 behavior of `to_time` returning a `Time` object with local timezone.
857
126
 
858
- *Sam Bostock*
859
-
860
- * Fix `Time#change` and `Time#advance` for times around the end of Daylight
861
- Saving Time.
862
-
863
- Previously, when `Time#change` or `Time#advance` constructed a time inside
864
- the final stretch of Daylight Saving Time (DST), the non-DST offset would
865
- always be chosen for local times:
866
-
867
- ```ruby
868
- # DST ended just before 2021-11-07 2:00:00 AM in US/Eastern.
869
- ENV["TZ"] = "US/Eastern"
870
-
871
- time = Time.local(2021, 11, 07, 00, 59, 59) + 1
872
- # => 2021-11-07 01:00:00 -0400
873
- time.change(day: 07)
874
- # => 2021-11-07 01:00:00 -0500
875
- time.advance(seconds: 0)
876
- # => 2021-11-07 01:00:00 -0500
877
-
878
- time = Time.local(2021, 11, 06, 01, 00, 00)
879
- # => 2021-11-06 01:00:00 -0400
880
- time.change(day: 07)
881
- # => 2021-11-07 01:00:00 -0500
882
- time.advance(days: 1)
883
- # => 2021-11-07 01:00:00 -0500
884
- ```
885
-
886
- And the DST offset would always be chosen for times with a `TimeZone`
887
- object:
888
-
889
- ```ruby
890
- Time.zone = "US/Eastern"
891
-
892
- time = Time.new(2021, 11, 07, 02, 00, 00, Time.zone) - 3600
893
- # => 2021-11-07 01:00:00 -0500
894
- time.change(day: 07)
895
- # => 2021-11-07 01:00:00 -0400
896
- time.advance(seconds: 0)
897
- # => 2021-11-07 01:00:00 -0400
898
-
899
- time = Time.new(2021, 11, 8, 01, 00, 00, Time.zone)
900
- # => 2021-11-08 01:00:00 -0500
901
- time.change(day: 07)
902
- # => 2021-11-07 01:00:00 -0400
903
- time.advance(days: -1)
904
- # => 2021-11-07 01:00:00 -0400
905
- ```
906
-
907
- Now, `Time#change` and `Time#advance` will choose the offset that matches
908
- the original time's offset when possible:
909
-
910
- ```ruby
911
- ENV["TZ"] = "US/Eastern"
912
-
913
- time = Time.local(2021, 11, 07, 00, 59, 59) + 1
914
- # => 2021-11-07 01:00:00 -0400
915
- time.change(day: 07)
916
- # => 2021-11-07 01:00:00 -0400
917
- time.advance(seconds: 0)
918
- # => 2021-11-07 01:00:00 -0400
919
-
920
- time = Time.local(2021, 11, 06, 01, 00, 00)
921
- # => 2021-11-06 01:00:00 -0400
922
- time.change(day: 07)
923
- # => 2021-11-07 01:00:00 -0400
924
- time.advance(days: 1)
925
- # => 2021-11-07 01:00:00 -0400
926
-
927
- Time.zone = "US/Eastern"
928
-
929
- time = Time.new(2021, 11, 07, 02, 00, 00, Time.zone) - 3600
930
- # => 2021-11-07 01:00:00 -0500
931
- time.change(day: 07)
932
- # => 2021-11-07 01:00:00 -0500
933
- time.advance(seconds: 0)
934
- # => 2021-11-07 01:00:00 -0500
935
-
936
- time = Time.new(2021, 11, 8, 01, 00, 00, Time.zone)
937
- # => 2021-11-08 01:00:00 -0500
938
- time.change(day: 07)
939
- # => 2021-11-07 01:00:00 -0500
940
- time.advance(days: -1)
941
- # => 2021-11-07 01:00:00 -0500
942
- ```
127
+ *Rafael Mendonça França*
943
128
 
944
- *Kevin Hall*, *Takayoshi Nishida*, and *Jonathan Hefner*
129
+ * Deprecate `config.active_support.to_time_preserves_timezone`.
945
130
 
946
- * Fix MemoryStore to preserve entries TTL when incrementing or decrementing
131
+ *Rafael Mendonça França*
947
132
 
948
- This is to be more consistent with how MemCachedStore and RedisCacheStore behaves.
133
+ * Deprecate `DateAndTime::Compatibility.preserve_timezone`.
949
134
 
950
- *Jean Boussier*
135
+ *Rafael Mendonça França*
951
136
 
952
- * `Rails.error.handle` and `Rails.error.record` filter now by multiple error classes.
137
+ * Yield instance to `Object#with` block.
953
138
 
954
139
  ```ruby
955
- Rails.error.handle(IOError, ArgumentError) do
956
- 1 + '1' # raises TypeError
140
+ client.with(timeout: 5_000) do |c|
141
+ c.get("/commits")
957
142
  end
958
- 1 + 1 # TypeErrors are not IOErrors or ArgumentError, so this will *not* be handled
959
143
  ```
960
144
 
961
- *Martin Spickermann*
962
-
963
- * `Class#subclasses` and `Class#descendants` now automatically filter reloaded classes.
145
+ *Sean Doyle*
964
146
 
965
- Previously they could return old implementations of reloadable classes that have been
966
- dereferenced but not yet garbage collected.
147
+ * Use logical core count instead of physical core count to determine the
148
+ default number of workers when parallelizing tests.
967
149
 
968
- They now automatically filter such classes like `DescendantTracker#subclasses` and
969
- `DescendantTracker#descendants`.
970
-
971
- *Jean Boussier*
972
-
973
- * `Rails.error.report` now marks errors as reported to avoid reporting them twice.
150
+ *Jonathan Hefner*
974
151
 
975
- In some cases, users might want to report errors explicitly with some extra context
976
- before letting it bubble up.
152
+ * Fix `Time.now/DateTime.now/Date.today` to return results in a system timezone after `#travel_to`.
977
153
 
978
- This also allows to safely catch and report errors outside of the execution context.
154
+ There is a bug in the current implementation of #travel_to:
155
+ it remembers a timezone of its argument, and all stubbed methods start
156
+ returning results in that remembered timezone. However, the expected
157
+ behavior is to return results in a system timezone.
979
158
 
980
- *Jean Boussier*
159
+ *Aleksei Chernenkov*
981
160
 
982
- * Add `assert_error_reported` and `assert_no_error_reported`
161
+ * Add `ErrorReported#unexpected` to report precondition violations.
983
162
 
984
- Allows to easily asserts an error happened but was handled
163
+ For example:
985
164
 
986
165
  ```ruby
987
- report = assert_error_reported(IOError) do
166
+ def edit
167
+ if published?
168
+ Rails.error.unexpected("[BUG] Attempting to edit a published article, that shouldn't be possible")
169
+ return false
170
+ end
988
171
  # ...
989
172
  end
990
- assert_equal "Oops", report.error.message
991
- assert_equal "admin", report.context[:section]
992
- assert_equal :warning, report.severity
993
- assert_predicate report, :handled?
994
- ```
995
-
996
- *Jean Boussier*
997
-
998
- * `ActiveSupport::Deprecation` behavior callbacks can now receive the
999
- deprecator instance as an argument. This makes it easier for such callbacks
1000
- to change their behavior based on the deprecator's state. For example,
1001
- based on the deprecator's `debug` flag.
1002
-
1003
- 3-arity and splat-args callbacks such as the following will now be passed
1004
- the deprecator instance as their third argument:
1005
-
1006
- * `->(message, callstack, deprecator) { ... }`
1007
- * `->(*args) { ... }`
1008
- * `->(message, *other_args) { ... }`
1009
-
1010
- 2-arity and 4-arity callbacks such as the following will continue to behave
1011
- the same as before:
1012
-
1013
- * `->(message, callstack) { ... }`
1014
- * `->(message, callstack, deprecation_horizon, gem_name) { ... }`
1015
- * `->(message, callstack, *deprecation_details) { ... }`
1016
-
1017
- *Jonathan Hefner*
1018
-
1019
- * `ActiveSupport::Deprecation#disallowed_warnings` now affects the instance on
1020
- which it is configured.
1021
-
1022
- This means that individual `ActiveSupport::Deprecation` instances can be
1023
- configured with their own disallowed warnings, and the global
1024
- `ActiveSupport::Deprecation.disallowed_warnings` now only affects the global
1025
- `ActiveSupport::Deprecation.warn`.
1026
-
1027
- **Before**
1028
-
1029
- ```ruby
1030
- ActiveSupport::Deprecation.disallowed_warnings = ["foo"]
1031
- deprecator = ActiveSupport::Deprecation.new("2.0", "MyCoolGem")
1032
- deprecator.disallowed_warnings = ["bar"]
1033
-
1034
- ActiveSupport::Deprecation.warn("foo") # => raise ActiveSupport::DeprecationException
1035
- ActiveSupport::Deprecation.warn("bar") # => print "DEPRECATION WARNING: bar"
1036
- deprecator.warn("foo") # => raise ActiveSupport::DeprecationException
1037
- deprecator.warn("bar") # => print "DEPRECATION WARNING: bar"
1038
- ```
1039
-
1040
- **After**
1041
-
1042
- ```ruby
1043
- ActiveSupport::Deprecation.disallowed_warnings = ["foo"]
1044
- deprecator = ActiveSupport::Deprecation.new("2.0", "MyCoolGem")
1045
- deprecator.disallowed_warnings = ["bar"]
1046
-
1047
- ActiveSupport::Deprecation.warn("foo") # => raise ActiveSupport::DeprecationException
1048
- ActiveSupport::Deprecation.warn("bar") # => print "DEPRECATION WARNING: bar"
1049
- deprecator.warn("foo") # => print "DEPRECATION WARNING: foo"
1050
- deprecator.warn("bar") # => raise ActiveSupport::DeprecationException
1051
173
  ```
1052
174
 
1053
- Note that global `ActiveSupport::Deprecation` methods such as `ActiveSupport::Deprecation.warn`
1054
- and `ActiveSupport::Deprecation.disallowed_warnings` have been deprecated.
1055
-
1056
- *Jonathan Hefner*
1057
-
1058
- * Add italic and underline support to `ActiveSupport::LogSubscriber#color`
1059
-
1060
- Previously, only bold text was supported via a positional argument.
1061
- This allows for bold, italic, and underline options to be specified
1062
- for colored logs.
1063
-
1064
- ```ruby
1065
- info color("Hello world!", :red, bold: true, underline: true)
1066
- ```
1067
-
1068
- *Gannon McGibbon*
1069
-
1070
- * Add `String#downcase_first` method.
1071
-
1072
- This method is the corollary of `String#upcase_first`.
1073
-
1074
- *Mark Schneider*
1075
-
1076
- * `thread_mattr_accessor` will call `.dup.freeze` on non-frozen default values.
1077
-
1078
- This provides a basic level of protection against different threads trying
1079
- to mutate a shared default object.
1080
-
1081
- *Jonathan Hefner*
1082
-
1083
- * Add `raise_on_invalid_cache_expiration_time` config to `ActiveSupport::Cache::Store`
1084
-
1085
- Specifies if an `ArgumentError` should be raised if `Rails.cache` `fetch` or
1086
- `write` are given an invalid `expires_at` or `expires_in` time.
1087
-
1088
- Options are `true`, and `false`. If `false`, the exception will be reported
1089
- as `handled` and logged instead. Defaults to `true` if `config.load_defaults >= 7.1`.
1090
-
1091
- *Trevor Turk*
1092
-
1093
- * `ActiveSupport::Cache::Store#fetch` now passes an options accessor to the block.
1094
-
1095
- It makes possible to override cache options:
1096
-
1097
- Rails.cache.fetch("3rd-party-token") do |name, options|
1098
- token = fetch_token_from_remote
1099
- # set cache's TTL to match token's TTL
1100
- options.expires_in = token.expires_in
1101
- token
1102
- end
1103
-
1104
- *Andrii Gladkyi*, *Jean Boussier*
1105
-
1106
- * `default` option of `thread_mattr_accessor` now applies through inheritance and
1107
- also across new threads.
1108
-
1109
- Previously, the `default` value provided was set only at the moment of defining
1110
- the attribute writer, which would cause the attribute to be uninitialized in
1111
- descendants and in other threads.
1112
-
1113
- Fixes #43312.
1114
-
1115
- *Thierry Deo*
1116
-
1117
- * Redis cache store is now compatible with redis-rb 5.0.
175
+ The above will raise an error in development and test, but only report the error in production.
1118
176
 
1119
177
  *Jean Boussier*
1120
178
 
1121
- * Add `skip_nil:` support to `ActiveSupport::Cache::Store#fetch_multi`.
1122
-
1123
- *Daniel Alfaro*
1124
-
1125
- * Add `quarter` method to date/time
1126
-
1127
- *Matt Swanson*
179
+ * Make the order of read_multi and write_multi notifications for `Cache::Store#fetch_multi` operations match the order they are executed in.
1128
180
 
1129
- * Fix `NoMethodError` on custom `ActiveSupport::Deprecation` behavior.
181
+ *Adam Renberg Tamm*
1130
182
 
1131
- `ActiveSupport::Deprecation.behavior=` was supposed to accept any object
1132
- that responds to `call`, but in fact its internal implementation assumed that
1133
- this object could respond to `arity`, so it was restricted to only `Proc` objects.
183
+ * Make return values of `Cache::Store#write` consistent.
1134
184
 
1135
- This change removes this `arity` restriction of custom behaviors.
185
+ The return value was not specified before. Now it returns `true` on a successful write,
186
+ `nil` if there was an error talking to the cache backend, and `false` if the write failed
187
+ for another reason (e.g. the key already exists and `unless_exist: true` was passed).
1136
188
 
1137
- *Ryo Nakamura*
189
+ *Sander Verdonschot*
1138
190
 
1139
- * Support `:url_safe` option for `MessageEncryptor`.
191
+ * Fix logged cache keys not always matching actual key used by cache action.
1140
192
 
1141
- The `MessageEncryptor` constructor now accepts a `:url_safe` option, similar
1142
- to the `MessageVerifier` constructor. When enabled, this option ensures
1143
- that messages use a URL-safe encoding.
193
+ *Hartley McGuire*
1144
194
 
1145
- *Jonathan Hefner*
195
+ * Improve error messages of `assert_changes` and `assert_no_changes`.
1146
196
 
1147
- * Add `url_safe` option to `ActiveSupport::MessageVerifier` initializer
197
+ `assert_changes` error messages now display objects with `.inspect` to make it easier
198
+ to differentiate nil from empty strings, strings from symbols, etc.
199
+ `assert_no_changes` error messages now surface the actual value.
1148
200
 
1149
- `ActiveSupport::MessageVerifier.new` now takes optional `url_safe` argument.
1150
- It can generate URL-safe strings by passing `url_safe: true`.
201
+ *pcreux*
1151
202
 
1152
- ```ruby
1153
- verifier = ActiveSupport::MessageVerifier.new(url_safe: true)
1154
- message = verifier.generate(data) # => URL-safe string
1155
- ```
203
+ * Fix `#to_fs(:human_size)` to correctly work with negative numbers.
1156
204
 
1157
- This option is `false` by default to be backwards compatible.
205
+ *Earlopain*
1158
206
 
1159
- *Shouichi Kamiya*
207
+ * Fix `BroadcastLogger#dup` so that it duplicates the logger's `broadcasts`.
1160
208
 
1161
- * Enable connection pooling by default for `MemCacheStore` and `RedisCacheStore`.
209
+ *Andrew Novoselac*
1162
210
 
1163
- If you want to disable connection pooling, set `:pool` option to `false` when configuring the cache store:
211
+ * Fix issue where `bootstrap.rb` overwrites the `level` of a `BroadcastLogger`'s `broadcasts`.
1164
212
 
1165
- ```ruby
1166
- config.cache_store = :mem_cache_store, "cache.example.com", pool: false
1167
- ```
213
+ *Andrew Novoselac*
1168
214
 
1169
- *fatkodima*
215
+ * Fix compatibility with the `semantic_logger` gem.
1170
216
 
1171
- * Add `force:` support to `ActiveSupport::Cache::Store#fetch_multi`.
217
+ The `semantic_logger` gem doesn't behave exactly like stdlib logger in that
218
+ `SemanticLogger#level` returns a Symbol while stdlib `Logger#level` returns an Integer.
1172
219
 
1173
- *fatkodima*
220
+ This caused the various `LogSubscriber` classes in Rails to break when assigned a
221
+ `SemanticLogger` instance.
1174
222
 
1175
- * Deprecated `:pool_size` and `:pool_timeout` options for configuring connection pooling in cache stores.
223
+ *Jean Boussier*, *ojab*
1176
224
 
1177
- Use `pool: true` to enable pooling with default settings:
225
+ * Fix MemoryStore to prevent race conditions when incrementing or decrementing.
1178
226
 
1179
- ```ruby
1180
- config.cache_store = :redis_cache_store, pool: true
1181
- ```
227
+ *Pierre Jambet*
1182
228
 
1183
- Or pass individual options via `:pool` option:
229
+ * Implement `HashWithIndifferentAccess#to_proc`.
1184
230
 
1185
- ```ruby
1186
- config.cache_store = :redis_cache_store, pool: { size: 10, timeout: 2 }
1187
- ```
231
+ Previously, calling `#to_proc` on `HashWithIndifferentAccess` object used inherited `#to_proc`
232
+ method from the `Hash` class, which was not able to access values using indifferent keys.
1188
233
 
1189
234
  *fatkodima*
1190
235
 
1191
- * Allow #increment and #decrement methods of `ActiveSupport::Cache::Store`
1192
- subclasses to set new values.
1193
-
1194
- Previously incrementing or decrementing an unset key would fail and return
1195
- nil. A default will now be assumed and the key will be created.
1196
-
1197
- *Andrej Blagojević*, *Eugene Kenny*
1198
-
1199
- * Add `skip_nil:` support to `RedisCacheStore`
1200
-
1201
- *Joey Paris*
1202
-
1203
- * `ActiveSupport::Cache::MemoryStore#write(name, val, unless_exist:true)` now
1204
- correctly writes expired keys.
1205
-
1206
- *Alan Savage*
1207
-
1208
- * `ActiveSupport::ErrorReporter` now accepts and forward a `source:` parameter.
1209
-
1210
- This allow libraries to signal the origin of the errors, and reporters
1211
- to easily ignore some sources.
1212
-
1213
- *Jean Boussier*
1214
-
1215
- * Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
1216
-
1217
- Add the method `ERB::Util.xml_name_escape` to escape dangerous characters
1218
- in names of tags and names of attributes, following the specification of XML.
1219
-
1220
- *Álvaro Martín Fraguas*
1221
-
1222
- * Respect `ActiveSupport::Logger.new`'s `:formatter` keyword argument
1223
-
1224
- The stdlib `Logger::new` allows passing a `:formatter` keyword argument to
1225
- set the logger's formatter. Previously `ActiveSupport::Logger.new` ignored
1226
- that argument by always setting the formatter to an instance of
1227
- `ActiveSupport::Logger::SimpleFormatter`.
1228
-
1229
- *Steven Harman*
1230
-
1231
- * Deprecate preserving the pre-Ruby 2.4 behavior of `to_time`
1232
-
1233
- With Ruby 2.4+ the default for +to_time+ changed from converting to the
1234
- local system time to preserving the offset of the receiver. At the time Rails
1235
- supported older versions of Ruby so a compatibility layer was added to assist
1236
- in the migration process. From Rails 5.0 new applications have defaulted to
1237
- the Ruby 2.4+ behavior and since Rails 7.0 now only supports Ruby 2.7+
1238
- this compatibility layer can be safely removed.
1239
-
1240
- To minimize any noise generated the deprecation warning only appears when the
1241
- setting is configured to `false` as that is the only scenario where the
1242
- removal of the compatibility layer has any effect.
1243
-
1244
- *Andrew White*
1245
-
1246
- * `Pathname.blank?` only returns true for `Pathname.new("")`
1247
-
1248
- Previously it would end up calling `Pathname#empty?` which returned true
1249
- if the path existed and was an empty directory or file.
1250
-
1251
- That behavior was unlikely to be expected.
1252
-
1253
- *Jean Boussier*
1254
-
1255
- * Deprecate `Notification::Event`'s `#children` and `#parent_of?`
1256
-
1257
- *John Hawthorn*
1258
-
1259
- * Change the default serializer of `ActiveSupport::MessageVerifier` from
1260
- `Marshal` to `ActiveSupport::JSON` when using `config.load_defaults 7.1`.
1261
-
1262
- Messages serialized with `Marshal` can still be read, but new messages will
1263
- be serialized with `ActiveSupport::JSON`. For more information, see
1264
- https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer.
1265
-
1266
- *Saba Kiaei*, *David Buckley*, and *Jonathan Hefner*
1267
-
1268
- * Change the default serializer of `ActiveSupport::MessageEncryptor` from
1269
- `Marshal` to `ActiveSupport::JSON` when using `config.load_defaults 7.1`.
1270
-
1271
- Messages serialized with `Marshal` can still be read, but new messages will
1272
- be serialized with `ActiveSupport::JSON`. For more information, see
1273
- https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer.
1274
-
1275
- *Zack Deveau*, *Martin Gingras*, and *Jonathan Hefner*
1276
-
1277
- * Add `ActiveSupport::TestCase#stub_const` to stub a constant for the duration of a yield.
1278
-
1279
- *DHH*
1280
-
1281
- * Fix `ActiveSupport::EncryptedConfiguration` to be compatible with Psych 4
1282
-
1283
- *Stephen Sugden*
1284
-
1285
- * Improve `File.atomic_write` error handling
1286
-
1287
- *Daniel Pepper*
1288
-
1289
- * Fix `Class#descendants` and `DescendantsTracker#descendants` compatibility with Ruby 3.1.
1290
-
1291
- [The native `Class#descendants` was reverted prior to Ruby 3.1 release](https://bugs.ruby-lang.org/issues/14394#note-33),
1292
- but `Class#subclasses` was kept, breaking the feature detection.
1293
-
1294
- *Jean Boussier*
1295
-
1296
- Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activesupport/CHANGELOG.md) for previous changes.
236
+ Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/activesupport/CHANGELOG.md) for previous changes.