activesupport 6.0.6.1 → 7.1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +865 -438
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +6 -6
  5. data/lib/active_support/actionable_error.rb +4 -2
  6. data/lib/active_support/array_inquirer.rb +4 -2
  7. data/lib/active_support/backtrace_cleaner.rb +30 -10
  8. data/lib/active_support/benchmarkable.rb +4 -3
  9. data/lib/active_support/broadcast_logger.rb +250 -0
  10. data/lib/active_support/builder.rb +1 -1
  11. data/lib/active_support/cache/coder.rb +153 -0
  12. data/lib/active_support/cache/entry.rb +134 -0
  13. data/lib/active_support/cache/file_store.rb +53 -20
  14. data/lib/active_support/cache/mem_cache_store.rb +208 -63
  15. data/lib/active_support/cache/memory_store.rb +120 -38
  16. data/lib/active_support/cache/null_store.rb +16 -2
  17. data/lib/active_support/cache/redis_cache_store.rb +201 -208
  18. data/lib/active_support/cache/serializer_with_fallback.rb +175 -0
  19. data/lib/active_support/cache/strategy/local_cache.rb +73 -66
  20. data/lib/active_support/cache.rb +539 -261
  21. data/lib/active_support/callbacks.rb +273 -142
  22. data/lib/active_support/code_generator.rb +65 -0
  23. data/lib/active_support/concern.rb +53 -7
  24. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +44 -7
  25. data/lib/active_support/concurrency/null_lock.rb +13 -0
  26. data/lib/active_support/concurrency/share_lock.rb +2 -2
  27. data/lib/active_support/configurable.rb +19 -6
  28. data/lib/active_support/configuration_file.rb +51 -0
  29. data/lib/active_support/core_ext/array/access.rb +1 -5
  30. data/lib/active_support/core_ext/array/conversions.rb +15 -13
  31. data/lib/active_support/core_ext/array/grouping.rb +6 -6
  32. data/lib/active_support/core_ext/array/inquiry.rb +2 -2
  33. data/lib/active_support/core_ext/benchmark.rb +2 -2
  34. data/lib/active_support/core_ext/big_decimal/conversions.rb +1 -1
  35. data/lib/active_support/core_ext/class/attribute.rb +34 -44
  36. data/lib/active_support/core_ext/class/subclasses.rb +19 -29
  37. data/lib/active_support/core_ext/date/blank.rb +1 -1
  38. data/lib/active_support/core_ext/date/calculations.rb +24 -9
  39. data/lib/active_support/core_ext/date/conversions.rb +18 -16
  40. data/lib/active_support/core_ext/date_and_time/calculations.rb +27 -4
  41. data/lib/active_support/core_ext/date_and_time/compatibility.rb +15 -0
  42. data/lib/active_support/core_ext/date_time/blank.rb +1 -1
  43. data/lib/active_support/core_ext/date_time/calculations.rb +4 -0
  44. data/lib/active_support/core_ext/date_time/conversions.rb +19 -15
  45. data/lib/active_support/core_ext/digest/uuid.rb +30 -13
  46. data/lib/active_support/core_ext/enumerable.rb +146 -72
  47. data/lib/active_support/core_ext/erb/util.rb +196 -0
  48. data/lib/active_support/core_ext/file/atomic.rb +3 -1
  49. data/lib/active_support/core_ext/hash/conversions.rb +3 -4
  50. data/lib/active_support/core_ext/hash/deep_merge.rb +22 -14
  51. data/lib/active_support/core_ext/hash/deep_transform_values.rb +4 -4
  52. data/lib/active_support/core_ext/hash/indifferent_access.rb +3 -3
  53. data/lib/active_support/core_ext/hash/keys.rb +5 -5
  54. data/lib/active_support/core_ext/hash/slice.rb +3 -2
  55. data/lib/active_support/core_ext/integer/inflections.rb +12 -12
  56. data/lib/active_support/core_ext/kernel/reporting.rb +4 -4
  57. data/lib/active_support/core_ext/kernel/singleton_class.rb +1 -1
  58. data/lib/active_support/core_ext/load_error.rb +1 -1
  59. data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
  60. data/lib/active_support/core_ext/module/attribute_accessors.rb +31 -29
  61. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +51 -20
  62. data/lib/active_support/core_ext/module/concerning.rb +14 -8
  63. data/lib/active_support/core_ext/module/delegation.rb +75 -42
  64. data/lib/active_support/core_ext/module/deprecation.rb +15 -12
  65. data/lib/active_support/core_ext/module/introspection.rb +1 -26
  66. data/lib/active_support/core_ext/name_error.rb +23 -2
  67. data/lib/active_support/core_ext/numeric/bytes.rb +9 -0
  68. data/lib/active_support/core_ext/numeric/conversions.rb +82 -73
  69. data/lib/active_support/core_ext/object/acts_like.rb +29 -5
  70. data/lib/active_support/core_ext/object/blank.rb +2 -2
  71. data/lib/active_support/core_ext/object/deep_dup.rb +17 -1
  72. data/lib/active_support/core_ext/object/duplicable.rb +15 -4
  73. data/lib/active_support/core_ext/object/inclusion.rb +13 -5
  74. data/lib/active_support/core_ext/object/instance_variables.rb +22 -12
  75. data/lib/active_support/core_ext/object/json.rb +52 -28
  76. data/lib/active_support/core_ext/object/to_query.rb +2 -4
  77. data/lib/active_support/core_ext/object/try.rb +20 -20
  78. data/lib/active_support/core_ext/object/with.rb +44 -0
  79. data/lib/active_support/core_ext/object/with_options.rb +25 -6
  80. data/lib/active_support/core_ext/object.rb +1 -0
  81. data/lib/active_support/core_ext/pathname/blank.rb +16 -0
  82. data/lib/active_support/core_ext/pathname/existence.rb +23 -0
  83. data/lib/active_support/core_ext/pathname.rb +4 -0
  84. data/lib/active_support/core_ext/range/compare_range.rb +6 -25
  85. data/lib/active_support/core_ext/range/conversions.rb +34 -13
  86. data/lib/active_support/core_ext/range/each.rb +1 -1
  87. data/lib/active_support/core_ext/range/overlap.rb +40 -0
  88. data/lib/active_support/core_ext/range.rb +1 -2
  89. data/lib/active_support/core_ext/regexp.rb +8 -1
  90. data/lib/active_support/core_ext/securerandom.rb +25 -13
  91. data/lib/active_support/core_ext/string/access.rb +5 -24
  92. data/lib/active_support/core_ext/string/conversions.rb +3 -2
  93. data/lib/active_support/core_ext/string/filters.rb +21 -15
  94. data/lib/active_support/core_ext/string/indent.rb +1 -1
  95. data/lib/active_support/core_ext/string/inflections.rb +51 -10
  96. data/lib/active_support/core_ext/string/inquiry.rb +2 -1
  97. data/lib/active_support/core_ext/string/multibyte.rb +2 -2
  98. data/lib/active_support/core_ext/string/output_safety.rb +85 -194
  99. data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -2
  100. data/lib/active_support/core_ext/symbol/starts_ends_with.rb +6 -0
  101. data/lib/active_support/core_ext/symbol.rb +3 -0
  102. data/lib/active_support/core_ext/thread/backtrace/location.rb +12 -0
  103. data/lib/active_support/core_ext/time/calculations.rb +46 -8
  104. data/lib/active_support/core_ext/time/conversions.rb +16 -13
  105. data/lib/active_support/core_ext/time/zones.rb +12 -28
  106. data/lib/active_support/core_ext.rb +2 -1
  107. data/lib/active_support/current_attributes/test_helper.rb +13 -0
  108. data/lib/active_support/current_attributes.rb +54 -22
  109. data/lib/active_support/deep_mergeable.rb +53 -0
  110. data/lib/active_support/dependencies/autoload.rb +17 -12
  111. data/lib/active_support/dependencies/interlock.rb +10 -18
  112. data/lib/active_support/dependencies/require_dependency.rb +28 -0
  113. data/lib/active_support/dependencies.rb +58 -769
  114. data/lib/active_support/deprecation/behaviors.rb +77 -38
  115. data/lib/active_support/deprecation/constant_accessor.rb +5 -4
  116. data/lib/active_support/deprecation/deprecators.rb +104 -0
  117. data/lib/active_support/deprecation/disallowed.rb +54 -0
  118. data/lib/active_support/deprecation/instance_delegator.rb +31 -5
  119. data/lib/active_support/deprecation/method_wrappers.rb +12 -28
  120. data/lib/active_support/deprecation/proxy_wrappers.rb +40 -25
  121. data/lib/active_support/deprecation/reporting.rb +76 -16
  122. data/lib/active_support/deprecation.rb +36 -4
  123. data/lib/active_support/deprecator.rb +7 -0
  124. data/lib/active_support/descendants_tracker.rb +150 -68
  125. data/lib/active_support/digest.rb +5 -3
  126. data/lib/active_support/duration/iso8601_parser.rb +3 -3
  127. data/lib/active_support/duration/iso8601_serializer.rb +24 -12
  128. data/lib/active_support/duration.rb +136 -56
  129. data/lib/active_support/encrypted_configuration.rb +72 -9
  130. data/lib/active_support/encrypted_file.rb +46 -13
  131. data/lib/active_support/environment_inquirer.rb +40 -0
  132. data/lib/active_support/error_reporter/test_helper.rb +15 -0
  133. data/lib/active_support/error_reporter.rb +203 -0
  134. data/lib/active_support/evented_file_update_checker.rb +86 -137
  135. data/lib/active_support/execution_context/test_helper.rb +13 -0
  136. data/lib/active_support/execution_context.rb +53 -0
  137. data/lib/active_support/execution_wrapper.rb +31 -12
  138. data/lib/active_support/executor/test_helper.rb +7 -0
  139. data/lib/active_support/file_update_checker.rb +4 -2
  140. data/lib/active_support/fork_tracker.rb +79 -0
  141. data/lib/active_support/gem_version.rb +5 -5
  142. data/lib/active_support/gzip.rb +2 -0
  143. data/lib/active_support/hash_with_indifferent_access.rb +86 -42
  144. data/lib/active_support/html_safe_translation.rb +53 -0
  145. data/lib/active_support/i18n.rb +2 -1
  146. data/lib/active_support/i18n_railtie.rb +29 -27
  147. data/lib/active_support/inflector/inflections.rb +26 -9
  148. data/lib/active_support/inflector/methods.rb +54 -64
  149. data/lib/active_support/inflector/transliterate.rb +7 -5
  150. data/lib/active_support/isolated_execution_state.rb +76 -0
  151. data/lib/active_support/json/decoding.rb +6 -5
  152. data/lib/active_support/json/encoding.rb +31 -45
  153. data/lib/active_support/key_generator.rb +32 -7
  154. data/lib/active_support/lazy_load_hooks.rb +33 -7
  155. data/lib/active_support/locale/en.yml +10 -4
  156. data/lib/active_support/log_subscriber/test_helper.rb +2 -2
  157. data/lib/active_support/log_subscriber.rb +101 -32
  158. data/lib/active_support/logger.rb +9 -60
  159. data/lib/active_support/logger_silence.rb +2 -26
  160. data/lib/active_support/logger_thread_safe_level.rb +24 -25
  161. data/lib/active_support/message_encryptor.rb +205 -58
  162. data/lib/active_support/message_encryptors.rb +141 -0
  163. data/lib/active_support/message_pack/cache_serializer.rb +23 -0
  164. data/lib/active_support/message_pack/extensions.rb +292 -0
  165. data/lib/active_support/message_pack/serializer.rb +63 -0
  166. data/lib/active_support/message_pack.rb +50 -0
  167. data/lib/active_support/message_verifier.rb +237 -86
  168. data/lib/active_support/message_verifiers.rb +135 -0
  169. data/lib/active_support/messages/codec.rb +65 -0
  170. data/lib/active_support/messages/metadata.rb +112 -46
  171. data/lib/active_support/messages/rotation_configuration.rb +2 -1
  172. data/lib/active_support/messages/rotation_coordinator.rb +93 -0
  173. data/lib/active_support/messages/rotator.rb +35 -32
  174. data/lib/active_support/messages/serializer_with_fallback.rb +158 -0
  175. data/lib/active_support/multibyte/chars.rb +15 -52
  176. data/lib/active_support/multibyte/unicode.rb +8 -122
  177. data/lib/active_support/multibyte.rb +1 -1
  178. data/lib/active_support/notifications/fanout.rb +310 -105
  179. data/lib/active_support/notifications/instrumenter.rb +113 -48
  180. data/lib/active_support/notifications.rb +56 -29
  181. data/lib/active_support/number_helper/number_converter.rb +15 -8
  182. data/lib/active_support/number_helper/number_to_currency_converter.rb +11 -6
  183. data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -1
  184. data/lib/active_support/number_helper/number_to_human_converter.rb +1 -1
  185. data/lib/active_support/number_helper/number_to_human_size_converter.rb +5 -5
  186. data/lib/active_support/number_helper/number_to_phone_converter.rb +2 -1
  187. data/lib/active_support/number_helper/number_to_rounded_converter.rb +9 -5
  188. data/lib/active_support/number_helper/rounding_helper.rb +12 -32
  189. data/lib/active_support/number_helper.rb +379 -304
  190. data/lib/active_support/option_merger.rb +11 -18
  191. data/lib/active_support/ordered_hash.rb +4 -4
  192. data/lib/active_support/ordered_options.rb +23 -3
  193. data/lib/active_support/parameter_filter.rb +104 -75
  194. data/lib/active_support/proxy_object.rb +2 -0
  195. data/lib/active_support/rails.rb +1 -4
  196. data/lib/active_support/railtie.rb +90 -6
  197. data/lib/active_support/reloader.rb +12 -4
  198. data/lib/active_support/rescuable.rb +18 -16
  199. data/lib/active_support/ruby_features.rb +7 -0
  200. data/lib/active_support/secure_compare_rotator.rb +58 -0
  201. data/lib/active_support/security_utils.rb +19 -12
  202. data/lib/active_support/string_inquirer.rb +5 -3
  203. data/lib/active_support/subscriber.rb +23 -47
  204. data/lib/active_support/syntax_error_proxy.rb +70 -0
  205. data/lib/active_support/tagged_logging.rb +84 -23
  206. data/lib/active_support/test_case.rb +166 -27
  207. data/lib/active_support/testing/assertions.rb +73 -20
  208. data/lib/active_support/testing/autorun.rb +0 -2
  209. data/lib/active_support/testing/constant_stubbing.rb +32 -0
  210. data/lib/active_support/testing/deprecation.rb +53 -2
  211. data/lib/active_support/testing/error_reporter_assertions.rb +107 -0
  212. data/lib/active_support/testing/isolation.rb +30 -29
  213. data/lib/active_support/testing/method_call_assertions.rb +24 -11
  214. data/lib/active_support/testing/parallelization/server.rb +82 -0
  215. data/lib/active_support/testing/parallelization/worker.rb +103 -0
  216. data/lib/active_support/testing/parallelization.rb +16 -95
  217. data/lib/active_support/testing/parallelize_executor.rb +81 -0
  218. data/lib/active_support/testing/stream.rb +4 -6
  219. data/lib/active_support/testing/strict_warnings.rb +39 -0
  220. data/lib/active_support/testing/tagged_logging.rb +1 -1
  221. data/lib/active_support/testing/time_helpers.rb +89 -19
  222. data/lib/active_support/time_with_zone.rb +105 -70
  223. data/lib/active_support/values/time_zone.rb +59 -26
  224. data/lib/active_support/version.rb +1 -1
  225. data/lib/active_support/xml_mini/jdom.rb +4 -11
  226. data/lib/active_support/xml_mini/libxml.rb +5 -5
  227. data/lib/active_support/xml_mini/libxmlsax.rb +1 -1
  228. data/lib/active_support/xml_mini/nokogiri.rb +5 -5
  229. data/lib/active_support/xml_mini/nokogirisax.rb +2 -2
  230. data/lib/active_support/xml_mini/rexml.rb +9 -2
  231. data/lib/active_support/xml_mini.rb +7 -6
  232. data/lib/active_support.rb +40 -1
  233. metadata +127 -40
  234. data/lib/active_support/core_ext/array/prepend_and_append.rb +0 -5
  235. data/lib/active_support/core_ext/hash/compact.rb +0 -5
  236. data/lib/active_support/core_ext/hash/transform_values.rb +0 -5
  237. data/lib/active_support/core_ext/marshal.rb +0 -24
  238. data/lib/active_support/core_ext/module/reachable.rb +0 -6
  239. data/lib/active_support/core_ext/numeric/inquiry.rb +0 -5
  240. data/lib/active_support/core_ext/range/include_range.rb +0 -9
  241. data/lib/active_support/core_ext/range/include_time_with_zone.rb +0 -23
  242. data/lib/active_support/core_ext/range/overlaps.rb +0 -10
  243. data/lib/active_support/core_ext/uri.rb +0 -25
  244. data/lib/active_support/dependencies/zeitwerk_integration.rb +0 -117
  245. data/lib/active_support/per_thread_registry.rb +0 -60
data/CHANGELOG.md CHANGED
@@ -1,782 +1,1209 @@
1
- ## Rails 6.0.6.1 (January 17, 2023) ##
1
+ ## Rails 7.1.3.2 (February 21, 2024) ##
2
2
 
3
3
  * No changes.
4
4
 
5
5
 
6
- ## Rails 6.0.6 (September 09, 2022) ##
6
+ ## Rails 7.1.3.1 (February 21, 2024) ##
7
7
 
8
8
  * No changes.
9
9
 
10
10
 
11
- ## Rails 6.0.5.1 (July 12, 2022) ##
11
+ ## Rails 7.1.3 (January 16, 2024) ##
12
12
 
13
- * No changes.
13
+ * Handle nil `backtrace_locations` in `ActiveSupport::SyntaxErrorProxy`.
14
14
 
15
+ *Eugene Kenny*
15
16
 
16
- ## Rails 6.0.5 (May 09, 2022) ##
17
+ * Fix `ActiveSupport::JSON.encode` to prevent duplicate keys.
17
18
 
18
- * No changes.
19
+ If the same key exist in both String and Symbol form it could
20
+ lead to the same key being emitted twice.
19
21
 
22
+ *Manish Sharma*
20
23
 
21
- ## Rails 6.0.4.8 (April 26, 2022) ##
24
+ * Fix `ActiveSupport::Cache::Store#read_multi` when using a cache namespace
25
+ and local cache strategy.
22
26
 
23
- * Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
27
+ *Mark Oleson*
24
28
 
25
- Add the method `ERB::Util.xml_name_escape` to escape dangerous characters
26
- in names of tags and names of attributes, following the specification of XML.
29
+ * Fix `Time.now/DateTime.now/Date.today` to return results in a system timezone after `#travel_to`.
27
30
 
28
- *Álvaro Martín Fraguas*
31
+ There is a bug in the current implementation of #travel_to:
32
+ it remembers a timezone of its argument, and all stubbed methods start
33
+ returning results in that remembered timezone. However, the expected
34
+ behaviour is to return results in a system timezone.
29
35
 
36
+ *Aleksei Chernenkov*
30
37
 
31
- ## Rails 6.0.4.7 (March 08, 2022) ##
38
+ * Fix `:unless_exist` option for `MemoryStore#write` (et al) when using a
39
+ cache namespace.
32
40
 
33
- * No changes.
41
+ *S. Brent Faulkner*
34
42
 
43
+ * Fix ActiveSupport::Deprecation to handle blaming generated code.
35
44
 
36
- ## Rails 6.0.4.6 (February 11, 2022) ##
45
+ *Jean Boussier*, *fatkodima*
37
46
 
38
- * Fix Reloader method signature to work with the new Executor signature
39
47
 
48
+ ## Rails 7.1.2 (November 10, 2023) ##
40
49
 
41
- ## Rails 6.0.4.5 (February 11, 2022) ##
50
+ * Fix `:expires_in` option for `RedisCacheStore#write_multi`.
42
51
 
43
- * No changes.
52
+ *fatkodima*
44
53
 
54
+ * Fix deserialization of non-string "purpose" field in Message serializer
45
55
 
46
- ## Rails 6.0.4.4 (December 15, 2021) ##
56
+ *Jacopo Beschi*
47
57
 
48
- * No changes.
58
+ * Prevent global cache options being overwritten when setting dynamic options
59
+ inside a `ActiveSupport::Cache::Store#fetch` block.
49
60
 
61
+ *Yasha Krasnou*
50
62
 
51
- ## Rails 6.0.4.3 (December 14, 2021) ##
63
+ * Fix missing `require` resulting in `NoMethodError` when running
64
+ `bin/rails secrets:show` or `bin/rails secrets:edit`.
52
65
 
53
- * No changes.
66
+ *Stephen Ierodiaconou*
54
67
 
68
+ * Ensure `{down,up}case_first` returns non-frozen string.
55
69
 
56
- ## Rails 6.0.4.2 (December 14, 2021) ##
70
+ *Jonathan Hefner*
57
71
 
58
- * No changes.
72
+ * Fix `#to_fs(:human_size)` to correctly work with negative numbers.
59
73
 
74
+ *Earlopain*
60
75
 
61
- ## Rails 6.0.4.1 (August 19, 2021) ##
76
+ * Fix `BroadcastLogger#dup` so that it duplicates the logger's `broadcasts`.
62
77
 
63
- * No changes.
78
+ *Andrew Novoselac*
64
79
 
80
+ * Fix issue where `bootstrap.rb` overwrites the `level` of a `BroadcastLogger`'s `broadcasts`.
65
81
 
66
- ## Rails 6.0.4 (June 15, 2021) ##
82
+ *Andrew Novoselac*
67
83
 
68
- * Fixed issue in `ActiveSupport::Cache::RedisCacheStore` not passing options
69
- to `read_multi` causing `fetch_multi` to not work properly.
84
+ * Fix `ActiveSupport::Cache` to handle outdated Marshal payload from Rails 6.1 format.
70
85
 
71
- *Rajesh Sharma*
86
+ Active Support's Cache is supposed to treat a Marshal payload that can no longer be
87
+ deserialized as a cache miss. It fail to do so for compressed payload in the Rails 6.1
88
+ legacy format.
72
89
 
73
- * `with_options` copies its options hash again to avoid leaking mutations.
90
+ *Jean Boussier*
74
91
 
75
- Fixes #39343.
92
+ * Fix `OrderedOptions#dig` for array indexes.
76
93
 
77
- *Eugene Kenny*
94
+ *fatkodima*
78
95
 
96
+ * Fix time travel helpers to work when nested using with separate classes.
79
97
 
80
- ## Rails 6.0.3.7 (May 05, 2021) ##
98
+ *fatkodima*
81
99
 
82
- * No changes.
100
+ * Fix `delete_matched` for file cache store to work with keys longer than the
101
+ max filename size.
83
102
 
103
+ *fatkodima* and *Jonathan Hefner*
84
104
 
85
- ## Rails 6.0.3.6 (March 26, 2021) ##
105
+ * Fix compatibility with the `semantic_logger` gem.
86
106
 
87
- * No changes.
107
+ The `semantic_logger` gem doesn't behave exactly like stdlib logger in that
108
+ `SemanticLogger#level` returns a Symbol while stdlib `Logger#level` returns an Integer.
88
109
 
110
+ This caused the various `LogSubscriber` classes in Rails to break when assigned a
111
+ `SemanticLogger` instance.
89
112
 
90
- ## Rails 6.0.3.5 (February 10, 2021) ##
113
+ *Jean Boussier*, *ojab*
91
114
 
92
- * No changes.
115
+ ## Rails 7.1.1 (October 11, 2023) ##
93
116
 
117
+ * Add support for keyword arguments when delegating calls to custom loggers from `ActiveSupport::BroadcastLogger`.
94
118
 
95
- ## Rails 6.0.3.4 (October 07, 2020) ##
119
+ *Edouard Chin*
96
120
 
97
- * No changes.
121
+ * `NumberHelper`: handle objects responding `to_d`.
98
122
 
123
+ *fatkodima*
99
124
 
100
- ## Rails 6.0.3.3 (September 09, 2020) ##
125
+ * Fix RedisCacheStore to properly set the TTL when incrementing or decrementing.
101
126
 
102
- * No changes.
127
+ This bug was only impacting Redis server older than 7.0.
128
+
129
+ *Thomas Countz*
103
130
 
131
+ * Fix MemoryStore to prevent race conditions when incrementing or decrementing.
104
132
 
105
- ## Rails 6.0.3.2 (June 17, 2020) ##
133
+ *Pierre Jambet*
134
+
135
+
136
+ ## Rails 7.1.0 (October 05, 2023) ##
106
137
 
107
138
  * No changes.
108
139
 
109
140
 
110
- ## Rails 6.0.3.1 (May 18, 2020) ##
141
+ ## Rails 7.1.0.rc2 (October 01, 2023) ##
111
142
 
112
- * [CVE-2020-8165] Deprecate Marshal.load on raw cache read in RedisCacheStore
143
+ * Fix `AS::MessagePack` with `ENV["RAILS_MAX_THREADS"]`.
113
144
 
114
- * [CVE-2020-8165] Avoid Marshal.load on raw cache value in MemCacheStore
145
+ *Jonathan Hefner*
115
146
 
116
147
 
117
- ## Rails 6.0.3 (May 06, 2020) ##
148
+ ## Rails 7.1.0.rc1 (September 27, 2023) ##
118
149
 
119
- * `Array#to_sentence` no longer returns a frozen string.
150
+ * Add a new public API for broadcasting logs
120
151
 
121
- Before:
152
+ This feature existed for a while but was until now a private API.
153
+ Broadcasting log allows to send log message to difference sinks (STDOUT, a file ...) and
154
+ is used by default in the development environment to write logs both on STDOUT and in the
155
+ "development.log" file.
122
156
 
123
- ['one', 'two'].to_sentence.frozen?
124
- # => true
157
+ Basic usage:
125
158
 
126
- After:
159
+ ```ruby
160
+ stdout_logger = Logger.new(STDOUT)
161
+ file_logger = Logger.new("development.log")
162
+ broadcast = ActiveSupport::BroadcastLogger.new(stdout_logger, file_logger)
127
163
 
128
- ['one', 'two'].to_sentence.frozen?
129
- # => false
164
+ broadcast.info("Hello!") # The "Hello!" message is written on STDOUT and in the log file.
165
+ ```
130
166
 
131
- *Nicolas Dular*
167
+ Adding other sink(s) to the broadcast:
132
168
 
133
- * Update `ActiveSupport::Messages::Metadata#fresh?` to work for cookies with expiry set when
134
- `ActiveSupport.parse_json_times = true`.
169
+ ```ruby
170
+ broadcast = ActiveSupport::BroadcastLogger.new
171
+ broadcast.broadcast_to(Logger.new(STDERR))
172
+ ```
135
173
 
136
- *Christian Gregg*
174
+ Remove a sink from the broadcast:
137
175
 
176
+ ```ruby
177
+ stdout_logger = Logger.new(STDOUT)
178
+ broadcast = ActiveSupport::BroadcastLogger.new(stdout_logger)
138
179
 
139
- ## Rails 6.0.2.2 (March 19, 2020) ##
180
+ broadcast.stop_broadcasting_to(stdout_logger)
181
+ ```
140
182
 
141
- * No changes.
183
+ *Edouard Chin*
142
184
 
185
+ * Fix Range#overlap? not taking empty ranges into account on Ruby < 3.3
143
186
 
144
- ## Rails 6.0.2.1 (December 18, 2019) ##
187
+ *Nobuyoshi Nakada*, *Shouichi Kamiya*, *Hartley McGuire*
145
188
 
146
- * No changes.
189
+ * Use Ruby 3.3 Range#overlap? if available
190
+
191
+ *Yasuo Honda*
147
192
 
148
193
 
149
- ## Rails 6.0.2 (December 13, 2019) ##
194
+ ## Rails 7.1.0.beta1 (September 13, 2023) ##
150
195
 
151
- * Eager load translations during initialization.
196
+ * Add `bigdecimal` as Active Support dependency that is a bundled gem candidate for Ruby 3.4.
152
197
 
153
- *Diego Plentz*
198
+ `bigdecimal` 3.1.4 or higher version will be installed.
199
+ Ruby 2.7 and 3.0 users who want `bigdecimal` version 2.0.0 or 3.0.0 behavior as a default gem,
200
+ pin the `bigdecimal` version in your application Gemfile.
154
201
 
155
- * Use per-thread CPU time clock on `ActiveSupport::Notifications`.
202
+ *Koichi ITO*
156
203
 
157
- *George Claghorn*
204
+ * Add `drb`, `mutex_m` and `base64` that are bundled gem candidates for Ruby 3.4
158
205
 
206
+ *Yasuo Honda*
159
207
 
160
- ## Rails 6.0.1 (November 5, 2019) ##
208
+ * When using cache format version >= 7.1 or a custom serializer, expired and
209
+ version-mismatched cache entries can now be detected without deserializing
210
+ their values.
161
211
 
162
- * `ActiveSupport::SafeBuffer` supports `Enumerator` methods.
212
+ *Jonathan Hefner*
163
213
 
164
- *Shugo Maeda*
214
+ * Make all cache stores return a boolean for `#delete`
165
215
 
166
- * The Redis cache store fails gracefully when the server returns a "max number
167
- of clients reached" error.
216
+ Previously the `RedisCacheStore#delete` would return `1` if the entry
217
+ exists and `0` otherwise. Now it returns true if the entry exists and false
218
+ otherwise, just like the other stores.
168
219
 
169
- *Brandon Medenwald*
220
+ The `FileStore` would return `nil` if the entry doesn't exists and returns
221
+ `false` now as well.
222
+
223
+ *Petrik de Heus*
224
+
225
+ * Active Support cache stores now support replacing the default compressor via
226
+ a `:compressor` option. The specified compressor must respond to `deflate`
227
+ and `inflate`. For example:
228
+
229
+ ```ruby
230
+ module MyCompressor
231
+ def self.deflate(string)
232
+ # compression logic...
233
+ end
234
+
235
+ def self.inflate(compressed)
236
+ # decompression logic...
237
+ end
238
+ end
170
239
 
171
- * Fixed that mutating a value returned by a memory cache store would
172
- unexpectedly change the cached value.
240
+ config.cache_store = :redis_cache_store, { compressor: MyCompressor }
241
+ ```
173
242
 
174
- *Jonathan Hyman*
243
+ *Jonathan Hefner*
175
244
 
176
- * The default inflectors in `zeitwerk` mode support overrides:
245
+ * Active Support cache stores now support a `:serializer` option. Similar to
246
+ the `:coder` option, serializers must respond to `dump` and `load`. However,
247
+ serializers are only responsible for serializing a cached value, whereas
248
+ coders are responsible for serializing the entire `ActiveSupport::Cache::Entry`
249
+ instance. Additionally, the output from serializers can be automatically
250
+ compressed, whereas coders are responsible for their own compression.
251
+
252
+ Specifying a serializer instead of a coder also enables performance
253
+ optimizations, including the bare string optimization introduced by cache
254
+ format version 7.1.
255
+
256
+ The `:serializer` and `:coder` options are mutually exclusive. Specifying
257
+ both will raise an `ArgumentError`.
258
+
259
+ *Jonathan Hefner*
260
+
261
+ * Fix `ActiveSupport::Inflector.humanize(nil)` raising ``NoMethodError: undefined method `end_with?' for nil:NilClass``.
262
+
263
+ *James Robinson*
264
+
265
+ * Don't show secrets for `ActiveSupport::KeyGenerator#inspect`.
266
+
267
+ Before:
177
268
 
178
269
  ```ruby
179
- # config/initializers/zeitwerk.rb
180
- Rails.autoloaders.each do |autoloader|
181
- autoloader.inflector.inflect(
182
- "html_parser" => "HTMLParser",
183
- "ssl_error" => "SSLError"
184
- )
185
- end
270
+ ActiveSupport::KeyGenerator.new(secret).inspect
271
+ "#<ActiveSupport::KeyGenerator:0x0000000104888038 ... @secret=\"\\xAF\\bFh]LV}q\\nl\\xB2U\\xB3 ... >"
272
+ ```
273
+
274
+ After:
275
+
276
+ ```ruby
277
+ ActiveSupport::KeyGenerator::Aes256Gcm(secret).inspect
278
+ "#<ActiveSupport::KeyGenerator:0x0000000104888038>"
186
279
  ```
187
280
 
188
- That way, you can tweak how individual basenames are inflected without touching Active Support inflection rules, which are global. These inflectors fallback to `String#camelize`, so existing inflection rules are still taken into account for non-overridden basenames.
281
+ *Petrik de Heus*
189
282
 
190
- Please, check the [autoloading guide for `zeitwerk` mode](https://guides.rubyonrails.org/v6.0/autoloading_and_reloading_constants.html#customizing-inflections) if you prefer not to depend on `String#camelize` at all.
283
+ * Improve error message when EventedFileUpdateChecker is used without a
284
+ compatible version of the Listen gem
191
285
 
192
- *Xavier Noria*
286
+ *Hartley McGuire*
193
287
 
194
- * Improve `Range#===`, `Range#include?`, and `Range#cover?` to work with beginless (startless)
195
- and endless range targets.
288
+ * Add `:report` behavior for Deprecation
196
289
 
197
- *Allen Hsu*, *Andrew Hodgkinson*
290
+ Setting `config.active_support.deprecation = :report` uses the error
291
+ reporter to report deprecation warnings to `ActiveSupport::ErrorReporter`.
198
292
 
199
- * Don't use `Process#clock_gettime(CLOCK_THREAD_CPUTIME_ID)` on Solaris.
293
+ Deprecations are reported as handled errors, with a severity of `:warning`.
200
294
 
201
- *Iain Beeston*
295
+ Useful to report deprecations happening in production to your bug tracker.
202
296
 
297
+ *Étienne Barrié*
203
298
 
204
- ## Rails 6.0.0 (August 16, 2019) ##
299
+ * Rename `Range#overlaps?` to `#overlap?` and add alias for backwards compatibility
205
300
 
206
- * Let `require_dependency` in `zeitwerk` mode look the autoload paths up for
207
- better backwards compatibility.
301
+ *Christian Schmidt*
208
302
 
209
- *Xavier Noria*
303
+ * Fix `EncryptedConfiguration` returning incorrect values for some `Hash`
304
+ methods
210
305
 
211
- * Let `require_dependency` in `zeitwerk` mode support arguments that respond
212
- to `to_path` for better backwards compatibility.
306
+ *Hartley McGuire*
213
307
 
214
- *Xavier Noria*
308
+ * Don't show secrets for `MessageEncryptor#inspect`.
215
309
 
216
- * Make ActiveSupport::Logger Fiber-safe. Fixes #36752.
310
+ Before:
217
311
 
218
- Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
219
- to make log level local to Ruby Fibers in addition to Threads.
312
+ ```ruby
313
+ ActiveSupport::MessageEncryptor.new(secret, cipher: "aes-256-gcm").inspect
314
+ "#<ActiveSupport::MessageEncryptor:0x0000000104888038 ... @secret=\"\\xAF\\bFh]LV}q\\nl\\xB2U\\xB3 ... >"
315
+ ```
220
316
 
221
- Example:
317
+ After:
222
318
 
223
- logger = ActiveSupport::Logger.new(STDOUT)
224
- logger.level = 1
225
- p "Main is debug? #{logger.debug?}"
319
+ ```ruby
320
+ ActiveSupport::MessageEncryptor.new(secret, cipher: "aes-256-gcm").inspect
321
+ "#<ActiveSupport::MessageEncryptor:0x0000000104888038>"
322
+ ```
226
323
 
227
- Fiber.new {
228
- logger.local_level = 0
229
- p "Thread is debug? #{logger.debug?}"
230
- }.resume
324
+ *Petrik de Heus*
231
325
 
232
- p "Main is debug? #{logger.debug?}"
326
+ * Don't show contents for `EncryptedConfiguration#inspect`.
233
327
 
234
328
  Before:
235
-
236
- Main is debug? false
237
- Thread is debug? true
238
- Main is debug? true
329
+ ```ruby
330
+ Rails.application.credentials.inspect
331
+ "#<ActiveSupport::EncryptedConfiguration:0x000000010d2b38e8 ... @config={:secret=>\"something secret\"} ... @key_file_contents=\"915e4ea054e011022398dc242\" ...>"
332
+ ```
239
333
 
240
334
  After:
335
+ ```ruby
336
+ Rails.application.credentials.inspect
337
+ "#<ActiveSupport::EncryptedConfiguration:0x000000010d2b38e8>"
338
+ ```
241
339
 
242
- Main is debug? false
243
- Thread is debug? true
244
- Main is debug? false
340
+ *Petrik de Heus*
245
341
 
246
- *Alexander Varnin*
342
+ * `ERB::Util.html_escape_once` always returns an `html_safe` string.
247
343
 
248
- * Do not delegate missing `marshal_dump` and `_dump` methods via the
249
- `delegate_missing_to` extension. This avoids unintentionally adding instance
250
- variables when calling `Marshal.dump(object)`, should the delegation target of
251
- `object` be a method which would otherwise add them. Fixes #36522.
344
+ This method previously maintained the `html_safe?` property of a string on the return
345
+ value. Because this string has been escaped, however, not marking it as `html_safe` causes
346
+ entities to be double-escaped.
252
347
 
253
- *Aaron Lipman*
348
+ As an example, take this view snippet:
254
349
 
350
+ ```html
351
+ <p><%= html_escape_once("this & that &amp; the other") %></p>
352
+ ```
255
353
 
256
- ## Rails 6.0.0.rc2 (July 22, 2019) ##
354
+ Before this change, that would be double-escaped and render as:
257
355
 
258
- * `truncate` would return the original string if it was too short to be truncated
259
- and a frozen string if it were long enough to be truncated. Now truncate will
260
- consistently return an unfrozen string regardless. This behavior is consistent
261
- with `gsub` and `strip`.
356
+ ```html
357
+ <p>this &amp;amp; that &amp;amp; the other</p>
358
+ ```
262
359
 
263
- Before:
360
+ After this change, it renders correctly as:
264
361
 
265
- 'foobar'.truncate(5).frozen?
266
- # => true
267
- 'foobar'.truncate(6).frozen?
268
- # => false
362
+ ```html
363
+ <p>this &amp; that &amp; the other</p>
364
+ ```
269
365
 
270
- After:
366
+ Fixes #48256
271
367
 
272
- 'foobar'.truncate(5).frozen?
273
- # => false
274
- 'foobar'.truncate(6).frozen?
275
- # => false
368
+ *Mike Dalessio*
276
369
 
277
- *Jordan Thomas*
370
+ * Deprecate `SafeBuffer#clone_empty`.
278
371
 
372
+ This method has not been used internally since Rails 4.2.0.
279
373
 
280
- ## Rails 6.0.0.rc1 (April 24, 2019) ##
374
+ *Mike Dalessio*
281
375
 
282
- * Speed improvements to `Hash.except` and `HashWithIndifferentAccess#except`.
376
+ * `MessageEncryptor`, `MessageVerifier`, and `config.active_support.message_serializer`
377
+ now accept `:message_pack` and `:message_pack_allow_marshal` as serializers.
378
+ These serializers require the [`msgpack` gem](https://rubygems.org/gems/msgpack)
379
+ (>= 1.7.0).
283
380
 
284
- These methods now unset the `default`/`default_proc` on the returned Hash, compatible with Ruby 3.0’s native implementation.
381
+ The Message Pack format can provide improved performance and smaller payload
382
+ sizes. It also supports round-tripping some Ruby types that are not supported
383
+ by JSON. For example:
285
384
 
286
- *Timo Schilling*
385
+ ```ruby
386
+ verifier = ActiveSupport::MessageVerifier.new("secret")
387
+ data = [{ a: 1 }, { b: 2 }.with_indifferent_access, 1.to_d, Time.at(0, 123)]
388
+ message = verifier.generate(data)
287
389
 
288
- * Introduce `ActiveSupport::ActionableError`.
390
+ # BEFORE with config.active_support.message_serializer = :json
391
+ verifier.verified(message)
392
+ # => [{"a"=>1}, {"b"=>2}, "1.0", "1969-12-31T18:00:00.000-06:00"]
393
+ verifier.verified(message).map(&:class)
394
+ # => [Hash, Hash, String, String]
289
395
 
290
- Actionable errors let's you dispatch actions from Rails' error pages. This
291
- can help you save time if you have a clear action for the resolution of
292
- common development errors.
396
+ # AFTER with config.active_support.message_serializer = :message_pack
397
+ verifier.verified(message)
398
+ # => [{:a=>1}, {"b"=>2}, 0.1e1, 1969-12-31 18:00:00.000123 -0600]
399
+ verifier.verified(message).map(&:class)
400
+ # => [Hash, ActiveSupport::HashWithIndifferentAccess, BigDecimal, Time]
401
+ ```
293
402
 
294
- The de-facto example are pending migrations. Every time pending migrations
295
- are found, a middleware raises an error. With actionable errors, you can
296
- run the migrations right from the error page. Other examples include Rails
297
- plugins that need to run a rake task to setup themselves. They can now
298
- raise actionable errors to run the setup straight from the error pages.
403
+ The `:message_pack` serializer can fall back to deserializing with
404
+ `ActiveSupport::JSON` when necessary, and the `:message_pack_allow_marshal`
405
+ serializer can fall back to deserializing with `Marshal` as well as
406
+ `ActiveSupport::JSON`. Additionally, the `:marshal`, `:json`, and
407
+ `:json_allow_marshal` serializers can now fall back to deserializing with
408
+ `ActiveSupport::MessagePack` when necessary. These behaviors ensure old
409
+ messages can still be read so that migration is easier.
299
410
 
300
- Here is how to define an actionable error:
411
+ *Jonathan Hefner*
412
+
413
+ * A new `7.1` cache format is available which includes an optimization for
414
+ bare string values such as view fragments.
415
+
416
+ The `7.1` cache format is used by default for new apps, and existing apps
417
+ can enable the format by setting `config.load_defaults 7.1` or by setting
418
+ `config.active_support.cache_format_version = 7.1` in `config/application.rb`
419
+ or a `config/environments/*.rb` file.
420
+
421
+ Cache entries written using the `6.1` or `7.0` cache formats can be read
422
+ when using the `7.1` format. To perform a rolling deploy of a Rails 7.1
423
+ upgrade, wherein servers that have not yet been upgraded must be able to
424
+ read caches from upgraded servers, leave the cache format unchanged on the
425
+ first deploy, then enable the `7.1` cache format on a subsequent deploy.
426
+
427
+ *Jonathan Hefner*
428
+
429
+ * Active Support cache stores can now use a preconfigured serializer based on
430
+ `ActiveSupport::MessagePack` via the `:serializer` option:
431
+
432
+ ```ruby
433
+ config.cache_store = :redis_cache_store, { serializer: :message_pack }
434
+ ```
435
+
436
+ The `:message_pack` serializer can reduce cache entry sizes and improve
437
+ performance, but requires the [`msgpack` gem](https://rubygems.org/gems/msgpack)
438
+ (>= 1.7.0).
439
+
440
+ The `:message_pack` serializer can read cache entries written by the default
441
+ serializer, and the default serializer can now read entries written by the
442
+ `:message_pack` serializer. These behaviors make it easy to migrate between
443
+ serializer without invalidating the entire cache.
444
+
445
+ *Jonathan Hefner*
446
+
447
+ * `Object#deep_dup` no longer duplicate named classes and modules.
448
+
449
+ Before:
301
450
 
302
451
  ```ruby
303
- class PendingMigrationError < MigrationError #:nodoc:
304
- include ActiveSupport::ActionableError
452
+ hash = { class: Object, module: Kernel }
453
+ hash.deep_dup # => {:class=>#<Class:0x00000001063ffc80>, :module=>#<Module:0x00000001063ffa00>}
454
+ ```
305
455
 
306
- action "Run pending migrations" do
307
- ActiveRecord::Tasks::DatabaseTasks.migrate
308
- end
456
+ After:
457
+
458
+ ```ruby
459
+ hash = { class: Object, module: Kernel }
460
+ hash.deep_dup # => {:class=>Object, :module=>Kernel}
461
+ ```
462
+
463
+ *Jean Boussier*
464
+
465
+ * Consistently raise an `ArgumentError` if the `ActiveSupport::Cache` key is blank.
466
+
467
+ *Joshua Young*
468
+
469
+ * Deprecate usage of the singleton `ActiveSupport::Deprecation`.
470
+
471
+ All usage of `ActiveSupport::Deprecation` as a singleton is deprecated, the most common one being
472
+ `ActiveSupport::Deprecation.warn`. Gem authors should now create their own deprecator (`ActiveSupport::Deprecation`
473
+ object), and use it to emit deprecation warnings.
474
+
475
+ Calling any of the following without specifying a deprecator argument is also deprecated:
476
+ * Module.deprecate
477
+ * deprecate_constant
478
+ * DeprecatedObjectProxy
479
+ * DeprecatedInstanceVariableProxy
480
+ * DeprecatedConstantProxy
481
+ * deprecation-related test assertions
482
+
483
+ Use of `ActiveSupport::Deprecation.silence` and configuration methods like `behavior=`, `disallowed_behavior=`,
484
+ `disallowed_warnings=` should now be aimed at the [application's deprecators](https://api.rubyonrails.org/classes/Rails/Application.html#method-i-deprecators).
485
+
486
+ ```ruby
487
+ Rails.application.deprecators.silence do
488
+ # code that emits deprecation warnings
309
489
  end
310
490
  ```
311
491
 
312
- To make an error actionable, include the `ActiveSupport::ActionableError`
313
- module and invoke the `action` class macro to define the action. An action
314
- needs a name and a procedure to execute. The name is shown as the name of a
315
- button on the error pages. Once clicked, it will invoke the given
316
- procedure.
492
+ If your gem has a Railtie or Engine, it's encouraged to add your deprecator to the application's deprecators, that
493
+ way the deprecation related configuration options will apply to it as well, e.g.
494
+ `config.active_support.report_deprecations` set to `false` in the production environment will also disable your
495
+ deprecator.
317
496
 
318
- *Vipul A M*, *Yao Jie*, *Genadi Samokovarov*
497
+ ```ruby
498
+ initializer "my_gem.deprecator" do |app|
499
+ app.deprecators[:my_gem] = MyGem.deprecator
500
+ end
501
+ ```
319
502
 
320
- * Preserve `html_safe?` status on `ActiveSupport::SafeBuffer#*`.
503
+ *Étienne Barrié*
321
504
 
322
- Before:
505
+ * Add `Object#with` to set and restore public attributes around a block
323
506
 
324
- ("<br />".html_safe * 2).html_safe? #=> nil
507
+ ```ruby
508
+ client.timeout # => 5
509
+ client.with(timeout: 1) do
510
+ client.timeout # => 1
511
+ end
512
+ client.timeout # => 5
513
+ ```
325
514
 
326
- After:
515
+ *Jean Boussier*
327
516
 
328
- ("<br />".html_safe * 2).html_safe? #=> true
517
+ * Remove deprecated support to generate incorrect RFC 4122 UUIDs when providing a namespace ID that is not one of the
518
+ constants defined on `Digest::UUID`.
329
519
 
330
- *Ryo Nakamura*
520
+ *Rafael Mendonça França*
521
+
522
+ * Deprecate `config.active_support.use_rfc4122_namespaced_uuids`.
523
+
524
+ *Rafael Mendonça França*
525
+
526
+ * Remove implicit conversion of objects into `String` by `ActiveSupport::SafeBuffer`.
331
527
 
332
- * Calling test methods with `with_info_handler` method to allow minitest-hooks
333
- plugin to work.
528
+ *Rafael Mendonça França*
334
529
 
335
- *Mauri Mustonen*
530
+ * Remove deprecated `active_support/core_ext/range/include_time_with_zone` file.
336
531
 
337
- * The Zeitwerk compatibility interface for `ActiveSupport::Dependencies` no
338
- longer implements `autoloaded_constants` or `autoloaded?` (undocumented,
339
- anyway). Experience shows introspection does not have many use cases, and
340
- troubleshooting is done by logging. With this design trade-off we are able
341
- to use even less memory in all environments.
532
+ *Rafael Mendonça França*
342
533
 
343
- *Xavier Noria*
534
+ * Deprecate `config.active_support.remove_deprecated_time_with_zone_name`.
344
535
 
345
- * Depends on Zeitwerk 2, which stores less metadata if reloading is disabled
346
- and hence uses less memory when `config.cache_classes` is `true`, a standard
347
- setup in production.
536
+ *Rafael Mendonça França*
348
537
 
349
- *Xavier Noria*
538
+ * Remove deprecated override of `ActiveSupport::TimeWithZone.name`.
350
539
 
351
- * In `:zeitwerk` mode, eager load directories in engines and applications only
352
- if present in their respective `config.eager_load_paths`.
540
+ *Rafael Mendonça França*
353
541
 
354
- A common use case for this is adding `lib` to `config.autoload_paths`, but
355
- not to `config.eager_load_paths`. In that configuration, for example, files
356
- in the `lib` directory should not be eager loaded.
542
+ * Deprecate `config.active_support.disable_to_s_conversion`.
357
543
 
358
- *Xavier Noria*
544
+ *Rafael Mendonça França*
359
545
 
360
- * Fix bug in Range comparisons when comparing to an excluded-end Range
546
+ * Remove deprecated option to passing a format to `#to_s` in `Array`, `Range`, `Date`, `DateTime`, `Time`,
547
+ `BigDecimal`, `Float` and, `Integer`.
361
548
 
362
- Before:
549
+ *Rafael Mendonça França*
363
550
 
364
- (1..10).cover?(1...11) # => false
551
+ * Remove deprecated `ActiveSupport::PerThreadRegistry`.
365
552
 
366
- After:
553
+ *Rafael Mendonça França*
367
554
 
368
- (1..10).cover?(1...11) # => true
555
+ * Remove deprecated override of `Enumerable#sum`.
369
556
 
370
- With the same change for `Range#include?` and `Range#===`.
557
+ *Rafael Mendonça França*
371
558
 
372
- *Owen Stephens*
559
+ * Deprecated initializing a `ActiveSupport::Cache::MemCacheStore` with an instance of `Dalli::Client`.
373
560
 
374
- * Use weak references in descendants tracker to allow anonymous subclasses to
375
- be garbage collected.
561
+ 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.
376
562
 
377
- *Edgars Beigarts*
563
+ *aledustet*
378
564
 
379
- * Update `ActiveSupport::Notifications::Instrumenter#instrument` to make
380
- passing a block optional. This will let users use
381
- `ActiveSupport::Notifications` messaging features outside of
382
- instrumentation.
565
+ * Stub `Time.new()` in `TimeHelpers#travel_to`
383
566
 
384
- *Ali Ibrahim*
567
+ ```ruby
568
+ travel_to Time.new(2004, 11, 24) do
569
+ # Inside the `travel_to` block `Time.new` is stubbed
570
+ assert_equal 2004, Time.new.year
571
+ end
572
+ ```
385
573
 
386
- * Fix `Time#advance` to work with dates before 1001-03-07
574
+ *fatkodima*
387
575
 
388
- Before:
576
+ * Raise `ActiveSupport::MessageEncryptor::InvalidMessage` from
577
+ `ActiveSupport::MessageEncryptor#decrypt_and_verify` regardless of cipher.
578
+ Previously, when a `MessageEncryptor` was using a non-AEAD cipher such as
579
+ AES-256-CBC, a corrupt or tampered message would raise
580
+ `ActiveSupport::MessageVerifier::InvalidSignature`. Now, all ciphers raise
581
+ the same error:
389
582
 
390
- Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-05 00:00:00 UTC
583
+ ```ruby
584
+ encryptor = ActiveSupport::MessageEncryptor.new("x" * 32, cipher: "aes-256-gcm")
585
+ message = encryptor.encrypt_and_sign("message")
586
+ encryptor.decrypt_and_verify(message.next)
587
+ # => raises ActiveSupport::MessageEncryptor::InvalidMessage
391
588
 
392
- After
589
+ encryptor = ActiveSupport::MessageEncryptor.new("x" * 32, cipher: "aes-256-cbc")
590
+ message = encryptor.encrypt_and_sign("message")
591
+ encryptor.decrypt_and_verify(message.next)
592
+ # BEFORE:
593
+ # => raises ActiveSupport::MessageVerifier::InvalidSignature
594
+ # AFTER:
595
+ # => raises ActiveSupport::MessageEncryptor::InvalidMessage
596
+ ```
393
597
 
394
- Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-06 00:00:00 UTC
598
+ *Jonathan Hefner*
395
599
 
396
- Note that this doesn't affect `DateTime#advance` as that doesn't use a proleptic calendar.
600
+ * Support `nil` original values when using `ActiveSupport::MessageVerifier#verify`.
601
+ Previously, `MessageVerifier#verify` did not work with `nil` original
602
+ values, though both `MessageVerifier#verified` and
603
+ `MessageEncryptor#decrypt_and_verify` do:
397
604
 
398
- *Andrew White*
605
+ ```ruby
606
+ encryptor = ActiveSupport::MessageEncryptor.new(secret)
607
+ message = encryptor.encrypt_and_sign(nil)
399
608
 
400
- * In Zeitwerk mode, engines are now managed by the `main` autoloader. Engines may reference application constants, if the application is reloaded and we do not reload engines, they won't use the reloaded application code.
609
+ encryptor.decrypt_and_verify(message)
610
+ # => nil
401
611
 
402
- *Xavier Noria*
612
+ verifier = ActiveSupport::MessageVerifier.new(secret)
613
+ message = verifier.generate(nil)
403
614
 
404
- * Add support for supplying `locale` to `transliterate` and `parameterize`.
615
+ verifier.verified(message)
616
+ # => nil
405
617
 
406
- I18n.backend.store_translations(:de, i18n: { transliterate: { rule: { "ü" => "ue" } } })
618
+ verifier.verify(message)
619
+ # BEFORE:
620
+ # => raises ActiveSupport::MessageVerifier::InvalidSignature
621
+ # AFTER:
622
+ # => nil
623
+ ```
407
624
 
408
- ActiveSupport::Inflector.transliterate("ü", locale: :de) # => "ue"
409
- "Fünf autos".parameterize(locale: :de) # => "fuenf-autos"
410
- ActiveSupport::Inflector.parameterize("Fünf autos", locale: :de) # => "fuenf-autos"
625
+ *Jonathan Hefner*
411
626
 
412
- *Kaan Ozkan*, *Sharang Dashputre*
627
+ * Maintain `html_safe?` on html_safe strings when sliced with `slice`, `slice!`, or `chr` method.
413
628
 
414
- * Allow `Array#excluding` and `Enumerable#excluding` to deal with a passed array gracefully.
629
+ Previously, `html_safe?` was only maintained when the html_safe strings were sliced
630
+ with `[]` method. Now, `slice`, `slice!`, and `chr` methods will maintain `html_safe?` like `[]` method.
415
631
 
416
- [ 1, 2, 3, 4, 5 ].excluding([4, 5]) # => [ 1, 2, 3 ]
632
+ ```ruby
633
+ string = "<div>test</div>".html_safe
634
+ string.slice(0, 1).html_safe? # => true
635
+ string.slice!(0, 1).html_safe? # => true
636
+ # maintain html_safe? after the slice!
637
+ string.html_safe? # => true
638
+ string.chr.html_safe? # => true
639
+ ```
417
640
 
418
- *DHH*
641
+ *Michael Go*
419
642
 
420
- * Renamed `Array#without` and `Enumerable#without` to `Array#excluding` and `Enumerable#excluding`, to create parity with
421
- `Array#including` and `Enumerable#including`. Retained the old names as aliases.
643
+ * Add `Object#in?` support for open ranges.
422
644
 
423
- *DHH*
645
+ ```ruby
646
+ assert Date.today.in?(..Date.tomorrow)
647
+ assert_not Date.today.in?(Date.tomorrow..)
648
+ ```
424
649
 
425
- * Added `Array#including` and `Enumerable#including` to conveniently enlarge a collection with more members using a method rather than an operator:
650
+ *Ignacio Galindo*
426
651
 
427
- [ 1, 2, 3 ].including(4, 5) # => [ 1, 2, 3, 4, 5 ]
428
- post.authors.including(Current.person) # => All the authors plus the current person!
652
+ * `config.i18n.raise_on_missing_translations = true` now raises on any missing translation.
429
653
 
430
- *DHH*
654
+ Previously it would only raise when called in a view or controller. Now it will raise
655
+ anytime `I18n.t` is provided an unrecognised key.
431
656
 
657
+ If you do not want this behaviour, you can customise the i18n exception handler. See the
658
+ upgrading guide or i18n guide for more information.
432
659
 
433
- ## Rails 6.0.0.beta3 (March 11, 2019) ##
660
+ *Alex Ghiculescu*
434
661
 
435
- * No changes.
662
+ * `ActiveSupport::CurrentAttributes` now raises if a restricted attribute name is used.
436
663
 
664
+ Attributes such as `set` and `reset` cannot be used as they clash with the
665
+ `CurrentAttributes` public API.
437
666
 
438
- ## Rails 6.0.0.beta2 (February 25, 2019) ##
667
+ *Alex Ghiculescu*
439
668
 
440
- * New autoloading based on [Zeitwerk](https://github.com/fxn/zeitwerk).
669
+ * `HashWithIndifferentAccess#transform_keys` now takes a Hash argument, just
670
+ as Ruby's `Hash#transform_keys` does.
441
671
 
442
- *Xavier Noria*
672
+ *Akira Matsuda*
443
673
 
444
- * Revise `ActiveSupport::Notifications.unsubscribe` to correctly handle Regex or other multiple-pattern subscribers.
674
+ * `delegate` now defines method with proper arity when delegating to a Class.
675
+ With this change, it defines faster method (3.5x faster with no argument).
676
+ However, in order to gain this benefit, the delegation target method has to
677
+ be defined before declaring the delegation.
445
678
 
446
- *Zach Kemp*
679
+ ```ruby
680
+ # This defines 3.5 times faster method than before
681
+ class C
682
+ def self.x() end
683
+ delegate :x, to: :class
684
+ end
447
685
 
448
- * Add `before_reset` callback to `CurrentAttributes` and define `after_reset` as an alias of `resets` for symmetry.
686
+ class C
687
+ # This works but silently falls back to old behavior because
688
+ # `delegate` cannot find the definition of `x`
689
+ delegate :x, to: :class
690
+ def self.x() end
691
+ end
692
+ ```
449
693
 
450
- *Rosa Gutierrez*
694
+ *Akira Matsuda*
451
695
 
452
- * Remove the `` Kernel#` `` override that suppresses ENOENT and accidentally returns nil on Unix systems.
696
+ * `assert_difference` message now includes what changed.
453
697
 
454
- *Akinori Musha*
698
+ This makes it easier to debug non-obvious failures.
455
699
 
456
- * Add `ActiveSupport::HashWithIndifferentAccess#assoc`.
700
+ Before:
457
701
 
458
- `assoc` can now be called with either a string or a symbol.
702
+ ```
703
+ "User.count" didn't change by 32.
704
+ Expected: 1611
705
+ Actual: 1579
706
+ ```
459
707
 
460
- *Stefan Schüßler*
708
+ After:
461
709
 
462
- * Add `Hash#deep_transform_values`, and `Hash#deep_transform_values!`.
710
+ ```
711
+ "User.count" didn't change by 32, but by 0.
712
+ Expected: 1611
713
+ Actual: 1579
714
+ ```
463
715
 
464
- *Guillermo Iguaran*
716
+ *Alex Ghiculescu*
465
717
 
718
+ * Add ability to match exception messages to `assert_raises` assertion
466
719
 
467
- ## Rails 6.0.0.beta1 (January 18, 2019) ##
720
+ Instead of this
721
+ ```ruby
722
+ error = assert_raises(ArgumentError) do
723
+ perform_service(param: 'exception')
724
+ end
725
+ assert_match(/incorrect param/i, error.message)
726
+ ```
468
727
 
469
- * Remove deprecated `Module#reachable?` method.
728
+ you can now write this
729
+ ```ruby
730
+ assert_raises(ArgumentError, match: /incorrect param/i) do
731
+ perform_service(param: 'exception')
732
+ end
733
+ ```
470
734
 
471
- *Rafael Mendonça França*
735
+ *fatkodima*
472
736
 
473
- * Remove deprecated `#acronym_regex` method from `Inflections`.
737
+ * Add `Rails.env.local?` shorthand for `Rails.env.development? || Rails.env.test?`.
474
738
 
475
- *Rafael Mendonça França*
739
+ *DHH*
476
740
 
477
- * Fix `String#safe_constantize` throwing a `LoadError` for incorrectly cased constant references.
741
+ * `ActiveSupport::Testing::TimeHelpers` now accepts named `with_usec` argument
742
+ to `freeze_time`, `travel`, and `travel_to` methods. Passing true prevents
743
+ truncating the destination time with `change(usec: 0)`.
478
744
 
479
- *Keenan Brock*
745
+ *KevSlashNull*, and *serprex*
480
746
 
481
- * Preserve key order passed to `ActiveSupport::CacheStore#fetch_multi`.
747
+ * `ActiveSupport::CurrentAttributes.resets` now accepts a method name
482
748
 
483
- `fetch_multi(*names)` now returns its results in the same order as the `*names` requested, rather than returning cache hits followed by cache misses.
749
+ The block API is still the recommended approach, but now both APIs are supported:
484
750
 
485
- *Gannon McGibbon*
751
+ ```ruby
752
+ class Current < ActiveSupport::CurrentAttributes
753
+ resets { Time.zone = nil }
754
+ resets :clear_time_zone
755
+ end
756
+ ```
486
757
 
487
- * If the same block is `included` multiple times for a Concern, an exception is no longer raised.
758
+ *Alex Ghiculescu*
488
759
 
489
- *Mark J. Titorenko*, *Vlad Bokov*
760
+ * Ensure `ActiveSupport::Testing::Isolation::Forking` closes pipes
490
761
 
491
- * Fix bug where `#to_options` for `ActiveSupport::HashWithIndifferentAccess`
492
- would not act as alias for `#symbolize_keys`.
762
+ Previously, `Forking.run_in_isolation` opened two ends of a pipe. The fork
763
+ process closed the read end, wrote to it, and then terminated (which
764
+ presumably closed the file descriptors on its end). The parent process
765
+ closed the write end, read from it, and returned, never closing the read
766
+ end.
493
767
 
494
- *Nick Weiland*
768
+ This resulted in an accumulation of open file descriptors, which could
769
+ cause errors if the limit is reached.
495
770
 
496
- * Improve the logic that detects non-autoloaded constants.
771
+ *Sam Bostock*
497
772
 
498
- *Jan Habermann*, *Xavier Noria*
773
+ * Fix `Time#change` and `Time#advance` for times around the end of Daylight
774
+ Saving Time.
499
775
 
500
- * Deprecate `ActiveSupport::Multibyte::Unicode#pack_graphemes(array)` and `ActiveSupport::Multibyte::Unicode#unpack_graphemes(string)`
501
- in favor of `array.flatten.pack("U*")` and `string.scan(/\X/).map(&:codepoints)`, respectively.
776
+ Previously, when `Time#change` or `Time#advance` constructed a time inside
777
+ the final stretch of Daylight Saving Time (DST), the non-DST offset would
778
+ always be chosen for local times:
502
779
 
503
- *Francesco Rodríguez*
780
+ ```ruby
781
+ # DST ended just before 2021-11-07 2:00:00 AM in US/Eastern.
782
+ ENV["TZ"] = "US/Eastern"
783
+
784
+ time = Time.local(2021, 11, 07, 00, 59, 59) + 1
785
+ # => 2021-11-07 01:00:00 -0400
786
+ time.change(day: 07)
787
+ # => 2021-11-07 01:00:00 -0500
788
+ time.advance(seconds: 0)
789
+ # => 2021-11-07 01:00:00 -0500
790
+
791
+ time = Time.local(2021, 11, 06, 01, 00, 00)
792
+ # => 2021-11-06 01:00:00 -0400
793
+ time.change(day: 07)
794
+ # => 2021-11-07 01:00:00 -0500
795
+ time.advance(days: 1)
796
+ # => 2021-11-07 01:00:00 -0500
797
+ ```
504
798
 
505
- * Deprecate `ActiveSupport::Multibyte::Chars.consumes?` in favor of `String#is_utf8?`.
799
+ And the DST offset would always be chosen for times with a `TimeZone`
800
+ object:
801
+
802
+ ```ruby
803
+ Time.zone = "US/Eastern"
804
+
805
+ time = Time.new(2021, 11, 07, 02, 00, 00, Time.zone) - 3600
806
+ # => 2021-11-07 01:00:00 -0500
807
+ time.change(day: 07)
808
+ # => 2021-11-07 01:00:00 -0400
809
+ time.advance(seconds: 0)
810
+ # => 2021-11-07 01:00:00 -0400
811
+
812
+ time = Time.new(2021, 11, 8, 01, 00, 00, Time.zone)
813
+ # => 2021-11-08 01:00:00 -0500
814
+ time.change(day: 07)
815
+ # => 2021-11-07 01:00:00 -0400
816
+ time.advance(days: -1)
817
+ # => 2021-11-07 01:00:00 -0400
818
+ ```
506
819
 
507
- *Francesco Rodríguez*
820
+ Now, `Time#change` and `Time#advance` will choose the offset that matches
821
+ the original time's offset when possible:
508
822
 
509
- * Fix duration being rounded to a full second.
823
+ ```ruby
824
+ ENV["TZ"] = "US/Eastern"
825
+
826
+ time = Time.local(2021, 11, 07, 00, 59, 59) + 1
827
+ # => 2021-11-07 01:00:00 -0400
828
+ time.change(day: 07)
829
+ # => 2021-11-07 01:00:00 -0400
830
+ time.advance(seconds: 0)
831
+ # => 2021-11-07 01:00:00 -0400
832
+
833
+ time = Time.local(2021, 11, 06, 01, 00, 00)
834
+ # => 2021-11-06 01:00:00 -0400
835
+ time.change(day: 07)
836
+ # => 2021-11-07 01:00:00 -0400
837
+ time.advance(days: 1)
838
+ # => 2021-11-07 01:00:00 -0400
839
+
840
+ Time.zone = "US/Eastern"
841
+
842
+ time = Time.new(2021, 11, 07, 02, 00, 00, Time.zone) - 3600
843
+ # => 2021-11-07 01:00:00 -0500
844
+ time.change(day: 07)
845
+ # => 2021-11-07 01:00:00 -0500
846
+ time.advance(seconds: 0)
847
+ # => 2021-11-07 01:00:00 -0500
848
+
849
+ time = Time.new(2021, 11, 8, 01, 00, 00, Time.zone)
850
+ # => 2021-11-08 01:00:00 -0500
851
+ time.change(day: 07)
852
+ # => 2021-11-07 01:00:00 -0500
853
+ time.advance(days: -1)
854
+ # => 2021-11-07 01:00:00 -0500
510
855
  ```
511
- time = DateTime.parse("2018-1-1")
512
- time += 0.51.seconds
856
+
857
+ *Kevin Hall*, *Takayoshi Nishida*, and *Jonathan Hefner*
858
+
859
+ * Fix MemoryStore to preserve entries TTL when incrementing or decrementing
860
+
861
+ This is to be more consistent with how MemCachedStore and RedisCacheStore behaves.
862
+
863
+ *Jean Boussier*
864
+
865
+ * `Rails.error.handle` and `Rails.error.record` filter now by multiple error classes.
866
+
867
+ ```ruby
868
+ Rails.error.handle(IOError, ArgumentError) do
869
+ 1 + '1' # raises TypeError
870
+ end
871
+ 1 + 1 # TypeErrors are not IOErrors or ArgumentError, so this will *not* be handled
513
872
  ```
514
- Will now correctly add 0.51 second and not 1 full second.
515
873
 
516
- *Edouard Chin*
874
+ *Martin Spickermann*
517
875
 
518
- * Deprecate `ActiveSupport::Multibyte::Unicode#normalize` and `ActiveSupport::Multibyte::Chars#normalize`
519
- in favor of `String#unicode_normalize`
876
+ * `Class#subclasses` and `Class#descendants` now automatically filter reloaded classes.
520
877
 
521
- *Francesco Rodríguez*
878
+ Previously they could return old implementations of reloadable classes that have been
879
+ dereferenced but not yet garbage collected.
522
880
 
523
- * Deprecate `ActiveSupport::Multibyte::Unicode#downcase/upcase/swapcase` in favor of
524
- `String#downcase/upcase/swapcase`.
881
+ They now automatically filter such classes like `DescendantTracker#subclasses` and
882
+ `DescendantTracker#descendants`.
525
883
 
526
- *Francesco Rodríguez*
884
+ *Jean Boussier*
527
885
 
528
- * Add `ActiveSupport::ParameterFilter`.
886
+ * `Rails.error.report` now marks errors as reported to avoid reporting them twice.
529
887
 
530
- *Yoshiyuki Kinjo*
888
+ In some cases, users might want to report errors explicitly with some extra context
889
+ before letting it bubble up.
531
890
 
532
- * Rename `Module#parent`, `Module#parents`, and `Module#parent_name` to
533
- `module_parent`, `module_parents`, and `module_parent_name`.
891
+ This also allows to safely catch and report errors outside of the execution context.
534
892
 
535
- *Gannon McGibbon*
893
+ *Jean Boussier*
536
894
 
537
- * Deprecate the use of `LoggerSilence` in favor of `ActiveSupport::LoggerSilence`
895
+ * Add `assert_error_reported` and `assert_no_error_reported`
538
896
 
539
- *Edouard Chin*
897
+ Allows to easily asserts an error happened but was handled
898
+
899
+ ```ruby
900
+ report = assert_error_reported(IOError) do
901
+ # ...
902
+ end
903
+ assert_equal "Oops", report.error.message
904
+ assert_equal "admin", report.context[:section]
905
+ assert_equal :warning, report.severity
906
+ assert_predicate report, :handled?
907
+ ```
540
908
 
541
- * Deprecate using negative limits in `String#first` and `String#last`.
909
+ *Jean Boussier*
542
910
 
543
- *Gannon McGibbon*, *Eric Turner*
911
+ * `ActiveSupport::Deprecation` behavior callbacks can now receive the
912
+ deprecator instance as an argument. This makes it easier for such callbacks
913
+ to change their behavior based on the deprecator's state. For example,
914
+ based on the deprecator's `debug` flag.
544
915
 
545
- * Fix bug where `#without` for `ActiveSupport::HashWithIndifferentAccess` would fail
546
- with symbol arguments
916
+ 3-arity and splat-args callbacks such as the following will now be passed
917
+ the deprecator instance as their third argument:
547
918
 
548
- *Abraham Chan*
919
+ * `->(message, callstack, deprecator) { ... }`
920
+ * `->(*args) { ... }`
921
+ * `->(message, *other_args) { ... }`
549
922
 
550
- * Treat `#delete_prefix`, `#delete_suffix` and `#unicode_normalize` results as non-`html_safe`.
551
- Ensure safety of arguments for `#insert`, `#[]=` and `#replace` calls on `html_safe` Strings.
923
+ 2-arity and 4-arity callbacks such as the following will continue to behave
924
+ the same as before:
552
925
 
553
- *Janosch Müller*
926
+ * `->(message, callstack) { ... }`
927
+ * `->(message, callstack, deprecation_horizon, gem_name) { ... }`
928
+ * `->(message, callstack, *deprecation_details) { ... }`
554
929
 
555
- * Changed `ActiveSupport::TaggedLogging.new` to return a new logger instance instead
556
- of mutating the one received as parameter.
930
+ *Jonathan Hefner*
557
931
 
558
- *Thierry Joyal*
932
+ * `ActiveSupport::Deprecation#disallowed_warnings` now affects the instance on
933
+ which it is configured.
559
934
 
560
- * Define `unfreeze_time` as an alias of `travel_back` in `ActiveSupport::Testing::TimeHelpers`.
935
+ This means that individual `ActiveSupport::Deprecation` instances can be
936
+ configured with their own disallowed warnings, and the global
937
+ `ActiveSupport::Deprecation.disallowed_warnings` now only affects the global
938
+ `ActiveSupport::Deprecation.warn`.
561
939
 
562
- The alias is provided for symmetry with `freeze_time`.
940
+ **Before**
563
941
 
564
- *Ryan Davidson*
942
+ ```ruby
943
+ ActiveSupport::Deprecation.disallowed_warnings = ["foo"]
944
+ deprecator = ActiveSupport::Deprecation.new("2.0", "MyCoolGem")
945
+ deprecator.disallowed_warnings = ["bar"]
946
+
947
+ ActiveSupport::Deprecation.warn("foo") # => raise ActiveSupport::DeprecationException
948
+ ActiveSupport::Deprecation.warn("bar") # => print "DEPRECATION WARNING: bar"
949
+ deprecator.warn("foo") # => raise ActiveSupport::DeprecationException
950
+ deprecator.warn("bar") # => print "DEPRECATION WARNING: bar"
951
+ ```
565
952
 
566
- * Add support for tracing constant autoloads. Just throw
953
+ **After**
567
954
 
568
- ActiveSupport::Dependencies.logger = Rails.logger
569
- ActiveSupport::Dependencies.verbose = true
955
+ ```ruby
956
+ ActiveSupport::Deprecation.disallowed_warnings = ["foo"]
957
+ deprecator = ActiveSupport::Deprecation.new("2.0", "MyCoolGem")
958
+ deprecator.disallowed_warnings = ["bar"]
959
+
960
+ ActiveSupport::Deprecation.warn("foo") # => raise ActiveSupport::DeprecationException
961
+ ActiveSupport::Deprecation.warn("bar") # => print "DEPRECATION WARNING: bar"
962
+ deprecator.warn("foo") # => print "DEPRECATION WARNING: foo"
963
+ deprecator.warn("bar") # => raise ActiveSupport::DeprecationException
964
+ ```
570
965
 
571
- in an initializer.
966
+ Note that global `ActiveSupport::Deprecation` methods such as `ActiveSupport::Deprecation.warn`
967
+ and `ActiveSupport::Deprecation.disallowed_warnings` have been deprecated.
572
968
 
573
- *Xavier Noria*
969
+ *Jonathan Hefner*
574
970
 
575
- * Maintain `html_safe?` on html_safe strings when sliced.
971
+ * Add italic and underline support to `ActiveSupport::LogSubscriber#color`
576
972
 
577
- string = "<div>test</div>".html_safe
578
- string[-1..1].html_safe? # => true
973
+ Previously, only bold text was supported via a positional argument.
974
+ This allows for bold, italic, and underline options to be specified
975
+ for colored logs.
579
976
 
580
- *Elom Gomez*, *Yumin Wong*
977
+ ```ruby
978
+ info color("Hello world!", :red, bold: true, underline: true)
979
+ ```
581
980
 
582
- * Add `Array#extract!`.
981
+ *Gannon McGibbon*
583
982
 
584
- The method removes and returns the elements for which the block returns a true value.
585
- If no block is given, an Enumerator is returned instead.
983
+ * Add `String#downcase_first` method.
586
984
 
587
- numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
588
- odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9]
589
- numbers # => [0, 2, 4, 6, 8]
985
+ This method is the corollary of `String#upcase_first`.
590
986
 
591
- *bogdanvlviv*
987
+ *Mark Schneider*
592
988
 
593
- * Support not to cache `nil` for `ActiveSupport::Cache#fetch`.
989
+ * `thread_mattr_accessor` will call `.dup.freeze` on non-frozen default values.
594
990
 
595
- cache.fetch('bar', skip_nil: true) { nil }
596
- cache.exist?('bar') # => false
991
+ This provides a basic level of protection against different threads trying
992
+ to mutate a shared default object.
597
993
 
598
- *Martin Hong*
994
+ *Jonathan Hefner*
599
995
 
600
- * Add "event object" support to the notification system.
601
- Before this change, end users were forced to create hand made artisanal
602
- event objects on their own, like this:
996
+ * Add `raise_on_invalid_cache_expiration_time` config to `ActiveSupport::Cache::Store`
603
997
 
604
- ActiveSupport::Notifications.subscribe('wait') do |*args|
605
- @event = ActiveSupport::Notifications::Event.new(*args)
606
- end
998
+ Specifies if an `ArgumentError` should be raised if `Rails.cache` `fetch` or
999
+ `write` are given an invalid `expires_at` or `expires_in` time.
607
1000
 
608
- ActiveSupport::Notifications.instrument('wait') do
609
- sleep 1
610
- end
1001
+ Options are `true`, and `false`. If `false`, the exception will be reported
1002
+ as `handled` and logged instead. Defaults to `true` if `config.load_defaults >= 7.1`.
611
1003
 
612
- @event.duration # => 1000.138
1004
+ *Trevor Turk*
613
1005
 
614
- After this change, if the block passed to `subscribe` only takes one
615
- parameter, the framework will yield an event object to the block. Now
616
- end users are no longer required to make their own:
1006
+ * `ActiveSupport::Cache::Store#fetch` now passes an options accessor to the block.
617
1007
 
618
- ActiveSupport::Notifications.subscribe('wait') do |event|
619
- @event = event
620
- end
1008
+ It makes possible to override cache options:
621
1009
 
622
- ActiveSupport::Notifications.instrument('wait') do
623
- sleep 1
1010
+ Rails.cache.fetch("3rd-party-token") do |name, options|
1011
+ token = fetch_token_from_remote
1012
+ # set cache's TTL to match token's TTL
1013
+ options.expires_in = token.expires_in
1014
+ token
624
1015
  end
625
1016
 
626
- p @event.allocations # => 7
627
- p @event.cpu_time # => 0.256
628
- p @event.idle_time # => 1003.2399
1017
+ *Andrii Gladkyi*, *Jean Boussier*
629
1018
 
630
- Now you can enjoy event objects without making them yourself. Neat!
1019
+ * `default` option of `thread_mattr_accessor` now applies through inheritance and
1020
+ also across new threads.
631
1021
 
632
- *Aaron "t.lo" Patterson*
1022
+ Previously, the `default` value provided was set only at the moment of defining
1023
+ the attribute writer, which would cause the attribute to be uninitialized in
1024
+ descendants and in other threads.
633
1025
 
634
- * Add cpu_time, idle_time, and allocations to Event.
1026
+ Fixes #43312.
635
1027
 
636
- *Eileen M. Uchitelle*, *Aaron Patterson*
1028
+ *Thierry Deo*
637
1029
 
638
- * RedisCacheStore: support key expiry in increment/decrement.
1030
+ * Redis cache store is now compatible with redis-rb 5.0.
639
1031
 
640
- Pass `:expires_in` to `#increment` and `#decrement` to set a Redis EXPIRE on the key.
1032
+ *Jean Boussier*
641
1033
 
642
- If the key is already set to expire, RedisCacheStore won't extend its expiry.
1034
+ * Add `skip_nil:` support to `ActiveSupport::Cache::Store#fetch_multi`.
643
1035
 
644
- Rails.cache.increment("some_key", 1, expires_in: 2.minutes)
1036
+ *Daniel Alfaro*
645
1037
 
646
- *Jason Lee*
1038
+ * Add `quarter` method to date/time
647
1039
 
648
- * Allow `Range#===` and `Range#cover?` on Range.
1040
+ *Matt Swanson*
649
1041
 
650
- `Range#cover?` can now accept a range argument like `Range#include?` and
651
- `Range#===`. `Range#===` works correctly on Ruby 2.6. `Range#include?` is moved
652
- into a new file, with these two methods.
1042
+ * Fix `NoMethodError` on custom `ActiveSupport::Deprecation` behavior.
653
1043
 
654
- *Requiring active_support/core_ext/range/include_range is now deprecated.*
655
- *Use `require "active_support/core_ext/range/compare_range"` instead.*
1044
+ `ActiveSupport::Deprecation.behavior=` was supposed to accept any object
1045
+ that responds to `call`, but in fact its internal implementation assumed that
1046
+ this object could respond to `arity`, so it was restricted to only `Proc` objects.
656
1047
 
657
- *utilum*
1048
+ This change removes this `arity` restriction of custom behaviors.
658
1049
 
659
- * Add `index_with` to Enumerable.
1050
+ *Ryo Nakamura*
660
1051
 
661
- Allows creating a hash from an enumerable with the value from a passed block
662
- or a default argument.
1052
+ * Support `:url_safe` option for `MessageEncryptor`.
663
1053
 
664
- %i( title body ).index_with { |attr| post.public_send(attr) }
665
- # => { title: "hey", body: "what's up?" }
1054
+ The `MessageEncryptor` constructor now accepts a `:url_safe` option, similar
1055
+ to the `MessageVerifier` constructor. When enabled, this option ensures
1056
+ that messages use a URL-safe encoding.
666
1057
 
667
- %i( title body ).index_with(nil)
668
- # => { title: nil, body: nil }
1058
+ *Jonathan Hefner*
669
1059
 
670
- Closely linked with `index_by`, which creates a hash where the keys are extracted from a block.
1060
+ * Add `url_safe` option to `ActiveSupport::MessageVerifier` initializer
671
1061
 
672
- *Kasper Timm Hansen*
1062
+ `ActiveSupport::MessageVerifier.new` now takes optional `url_safe` argument.
1063
+ It can generate URL-safe strings by passing `url_safe: true`.
673
1064
 
674
- * Fix bug where `ActiveSupport::TimeZone.all` would fail when tzinfo data for
675
- any timezone defined in `ActiveSupport::TimeZone::MAPPING` is missing.
1065
+ ```ruby
1066
+ verifier = ActiveSupport::MessageVerifier.new(url_safe: true)
1067
+ message = verifier.generate(data) # => URL-safe string
1068
+ ```
676
1069
 
677
- *Dominik Sander*
1070
+ This option is `false` by default to be backwards compatible.
678
1071
 
679
- * Redis cache store: `delete_matched` no longer blocks the Redis server.
680
- (Switches from evaled Lua to a batched SCAN + DEL loop.)
1072
+ *Shouichi Kamiya*
681
1073
 
682
- *Gleb Mazovetskiy*
1074
+ * Enable connection pooling by default for `MemCacheStore` and `RedisCacheStore`.
683
1075
 
684
- * Fix bug where `ActiveSupport::Cache` will massively inflate the storage
685
- size when compression is enabled (which is true by default). This patch
686
- does not attempt to repair existing data: please manually flush the cache
687
- to clear out the problematic entries.
1076
+ If you want to disable connection pooling, set `:pool` option to `false` when configuring the cache store:
688
1077
 
689
- *Godfrey Chan*
1078
+ ```ruby
1079
+ config.cache_store = :mem_cache_store, "cache.example.com", pool: false
1080
+ ```
690
1081
 
691
- * Fix bug where `URI.unescape` would fail with mixed Unicode/escaped character input:
1082
+ *fatkodima*
692
1083
 
693
- URI.unescape("\xe3\x83\x90") # => "バ"
694
- URI.unescape("%E3%83%90") # => "バ"
695
- URI.unescape("\xe3\x83\x90%E3%83%90") # => Encoding::CompatibilityError
1084
+ * Add `force:` support to `ActiveSupport::Cache::Store#fetch_multi`.
696
1085
 
697
- *Ashe Connor*, *Aaron Patterson*
1086
+ *fatkodima*
698
1087
 
699
- * Add `before?` and `after?` methods to `Date`, `DateTime`,
700
- `Time`, and `TimeWithZone`.
1088
+ * Deprecated `:pool_size` and `:pool_timeout` options for configuring connection pooling in cache stores.
701
1089
 
702
- *Nick Holden*
1090
+ Use `pool: true` to enable pooling with default settings:
703
1091
 
704
- * `ActiveSupport::Inflector#ordinal` and `ActiveSupport::Inflector#ordinalize` now support
705
- translations through I18n.
1092
+ ```ruby
1093
+ config.cache_store = :redis_cache_store, pool: true
1094
+ ```
706
1095
 
707
- # locale/fr.rb
1096
+ Or pass individual options via `:pool` option:
708
1097
 
709
- {
710
- fr: {
711
- number: {
712
- nth: {
713
- ordinals: lambda do |_key, number:, **_options|
714
- if number.to_i.abs == 1
715
- 'er'
716
- else
717
- 'e'
718
- end
719
- end,
1098
+ ```ruby
1099
+ config.cache_store = :redis_cache_store, pool: { size: 10, timeout: 2 }
1100
+ ```
720
1101
 
721
- ordinalized: lambda do |_key, number:, **_options|
722
- "#{number}#{ActiveSupport::Inflector.ordinal(number)}"
723
- end
724
- }
725
- }
726
- }
727
- }
1102
+ *fatkodima*
728
1103
 
1104
+ * Allow #increment and #decrement methods of `ActiveSupport::Cache::Store`
1105
+ subclasses to set new values.
729
1106
 
730
- *Christian Blais*
1107
+ Previously incrementing or decrementing an unset key would fail and return
1108
+ nil. A default will now be assumed and the key will be created.
731
1109
 
732
- * Add `:private` option to ActiveSupport's `Module#delegate`
733
- in order to delegate methods as private:
1110
+ *Andrej Blagojević*, *Eugene Kenny*
734
1111
 
735
- class User < ActiveRecord::Base
736
- has_one :profile
737
- delegate :date_of_birth, to: :profile, private: true
1112
+ * Add `skip_nil:` support to `RedisCacheStore`
738
1113
 
739
- def age
740
- Date.today.year - date_of_birth.year
741
- end
742
- end
1114
+ *Joey Paris*
1115
+
1116
+ * `ActiveSupport::Cache::MemoryStore#write(name, val, unless_exist:true)` now
1117
+ correctly writes expired keys.
1118
+
1119
+ *Alan Savage*
1120
+
1121
+ * `ActiveSupport::ErrorReporter` now accepts and forward a `source:` parameter.
1122
+
1123
+ This allow libraries to signal the origin of the errors, and reporters
1124
+ to easily ignore some sources.
1125
+
1126
+ *Jean Boussier*
743
1127
 
744
- # User.new.age # => 29
745
- # User.new.date_of_birth
746
- # => NoMethodError: private method `date_of_birth' called for #<User:0x00000008221340>
1128
+ * Fix and add protections for XSS in `ActionView::Helpers` and `ERB::Util`.
747
1129
 
748
- *Tomas Valent*
1130
+ Add the method `ERB::Util.xml_name_escape` to escape dangerous characters
1131
+ in names of tags and names of attributes, following the specification of XML.
749
1132
 
750
- * `String#truncate_bytes` to truncate a string to a maximum bytesize without
751
- breaking multibyte characters or grapheme clusters like 👩‍👩‍👦‍👦.
1133
+ *Álvaro Martín Fraguas*
752
1134
 
753
- *Jeremy Daer*
1135
+ * Respect `ActiveSupport::Logger.new`'s `:formatter` keyword argument
754
1136
 
755
- * `String#strip_heredoc` preserves frozenness.
1137
+ The stdlib `Logger::new` allows passing a `:formatter` keyword argument to
1138
+ set the logger's formatter. Previously `ActiveSupport::Logger.new` ignored
1139
+ that argument by always setting the formatter to an instance of
1140
+ `ActiveSupport::Logger::SimpleFormatter`.
756
1141
 
757
- "foo".freeze.strip_heredoc.frozen? # => true
1142
+ *Steven Harman*
758
1143
 
759
- Fixes that frozen string literals would inadvertently become unfrozen:
1144
+ * Deprecate preserving the pre-Ruby 2.4 behavior of `to_time`
760
1145
 
761
- # frozen_string_literal: true
1146
+ With Ruby 2.4+ the default for +to_time+ changed from converting to the
1147
+ local system time to preserving the offset of the receiver. At the time Rails
1148
+ supported older versions of Ruby so a compatibility layer was added to assist
1149
+ in the migration process. From Rails 5.0 new applications have defaulted to
1150
+ the Ruby 2.4+ behavior and since Rails 7.0 now only supports Ruby 2.7+
1151
+ this compatibility layer can be safely removed.
1152
+
1153
+ To minimize any noise generated the deprecation warning only appears when the
1154
+ setting is configured to `false` as that is the only scenario where the
1155
+ removal of the compatibility layer has any effect.
1156
+
1157
+ *Andrew White*
762
1158
 
763
- foo = <<-MSG.strip_heredoc
764
- la la la
765
- MSG
1159
+ * `Pathname.blank?` only returns true for `Pathname.new("")`
766
1160
 
767
- foo.frozen? # => false !??
1161
+ Previously it would end up calling `Pathname#empty?` which returned true
1162
+ if the path existed and was an empty directory or file.
1163
+
1164
+ That behavior was unlikely to be expected.
1165
+
1166
+ *Jean Boussier*
1167
+
1168
+ * Deprecate `Notification::Event`'s `#children` and `#parent_of?`
1169
+
1170
+ *John Hawthorn*
1171
+
1172
+ * Change the default serializer of `ActiveSupport::MessageVerifier` from
1173
+ `Marshal` to `ActiveSupport::JSON` when using `config.load_defaults 7.1`.
1174
+
1175
+ Messages serialized with `Marshal` can still be read, but new messages will
1176
+ be serialized with `ActiveSupport::JSON`. For more information, see
1177
+ https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer.
1178
+
1179
+ *Saba Kiaei*, *David Buckley*, and *Jonathan Hefner*
1180
+
1181
+ * Change the default serializer of `ActiveSupport::MessageEncryptor` from
1182
+ `Marshal` to `ActiveSupport::JSON` when using `config.load_defaults 7.1`.
1183
+
1184
+ Messages serialized with `Marshal` can still be read, but new messages will
1185
+ be serialized with `ActiveSupport::JSON`. For more information, see
1186
+ https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer.
1187
+
1188
+ *Zack Deveau*, *Martin Gingras*, and *Jonathan Hefner*
1189
+
1190
+ * Add `ActiveSupport::TestCase#stub_const` to stub a constant for the duration of a yield.
1191
+
1192
+ *DHH*
768
1193
 
769
- *Jeremy Daer*
1194
+ * Fix `ActiveSupport::EncryptedConfiguration` to be compatible with Psych 4
770
1195
 
771
- * Rails 6 requires Ruby 2.5.0 or newer.
1196
+ *Stephen Sugden*
772
1197
 
773
- *Jeremy Daer*, *Kasper Timm Hansen*
1198
+ * Improve `File.atomic_write` error handling
774
1199
 
775
- * Adds parallel testing to Rails.
1200
+ *Daniel Pepper*
776
1201
 
777
- Parallelize your test suite with forked processes or threads.
1202
+ * Fix `Class#descendants` and `DescendantsTracker#descendants` compatibility with Ruby 3.1.
778
1203
 
779
- *Eileen M. Uchitelle*, *Aaron Patterson*
1204
+ [The native `Class#descendants` was reverted prior to Ruby 3.1 release](https://bugs.ruby-lang.org/issues/14394#note-33),
1205
+ but `Class#subclasses` was kept, breaking the feature detection.
780
1206
 
1207
+ *Jean Boussier*
781
1208
 
782
- Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activesupport/CHANGELOG.md) for previous changes.
1209
+ Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activesupport/CHANGELOG.md) for previous changes.