railties 7.0.3.1 → 7.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9bbab9c16ee4d39fb4ad931643beee7ca36d194bc31959a852a3300104da24c
4
- data.tar.gz: '0887b493b31b2ab787847ea01e142c61e736a489d76139de48f7812bdcce0f21'
3
+ metadata.gz: 8426dae672be312fe1692dddb173520cb38cab1d146901da4e8321a731c4d309
4
+ data.tar.gz: '086173aa65cfba04c54b052ad3725f2cb55caafc7b2eef3255883f86a51dea3b'
5
5
  SHA512:
6
- metadata.gz: afd674b56dcc7b2dc0f3cfd0d046ccad471f7d619dd5ef9877e7fa085ea5da296983322b363e0e40a19549cf97b9f761650340b284a23d904a5b4fa9e521830a
7
- data.tar.gz: 40b75b6ebaa9aaf1ac693ca4bd7622b5b50a5089b4f78a9ac44142a1e2639fe91a5eb1c1f85a902d9e274ddfa54e77827a0e56dc295157bb4aa9645ffa774aa5
6
+ metadata.gz: 3a936aed24714e95363c55d50c008a2d85a4b22951647172b79b7d5faaaa2b49dce611f43bc6099001cc400b91614a49f003f5c68834c218596434c2d6e5ae71
7
+ data.tar.gz: b863940381ffc5819d6cd191735d30af40603d04946630781ab01ba6d0b6ab3ead22449b95f99fca4f84bbfa06b85b6aa9d3d05cce5ab1df0bd2a8841420d76e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ ## Rails 7.0.4 (September 09, 2022) ##
2
+
3
+ * `config.allow_concurrency = false` now use a `Monitor` instead of a `Mutex`
4
+
5
+ This allows to enable `config.active_support.executor_around_test_case` even
6
+ when `config.allow_concurrency` is disabled.
7
+
8
+ *Jean Boussier*
9
+
10
+ * Skip Active Storage and Action Mailer if Active Job is skipped.
11
+
12
+ *Étienne Barrié*
13
+
14
+ * Correctly check if frameworks are disabled when running app:update.
15
+
16
+ *Étienne Barrié* and *Paulo Barros*
17
+
18
+ * Fixed `config.active_support.cache_format_version` never being applied.
19
+
20
+ Rails 7.0 shipped with a new serializer for Rails.cache, but the associated config
21
+ wasn't working properly. Note that even after this fix, it can only be applied from
22
+ the `application.rb` file.
23
+
24
+ *Alex Ghiculescu*
25
+
26
+
1
27
  ## Rails 7.0.3.1 (July 12, 2022) ##
2
28
 
3
29
  * No changes.
@@ -21,10 +21,15 @@ module Rails
21
21
  private
22
22
  def generator_options
23
23
  options = { api: !!Rails.application.config.api_only, update: true }
24
+ options[:skip_active_job] = !defined?(ActiveJob::Railtie)
24
25
  options[:skip_active_record] = !defined?(ActiveRecord::Railtie)
25
- options[:skip_active_storage] = !defined?(ActiveStorage::Engine) || !defined?(ActiveRecord::Railtie)
26
+ options[:skip_active_storage] = !defined?(ActiveStorage::Engine)
26
27
  options[:skip_action_mailer] = !defined?(ActionMailer::Railtie)
28
+ options[:skip_action_mailbox] = !defined?(ActionMailbox::Engine)
29
+ options[:skip_action_text] = !defined?(ActionText::Engine)
27
30
  options[:skip_action_cable] = !defined?(ActionCable::Engine)
31
+ options[:skip_test] = !defined?(Rails::TestUnitRailtie)
32
+ options[:skip_system_test] = Rails.application.config.generators.system_tests.nil?
28
33
  options[:skip_asset_pipeline] = !defined?(Sprockets::Railtie) && !defined?(Propshaft::Railtie)
29
34
  options[:skip_bootsnap] = !defined?(Bootsnap)
30
35
  options[:updating] = true
@@ -59,6 +59,9 @@ module Rails
59
59
 
60
60
  # Initialize cache early in the stack so railties can make use of it.
61
61
  initializer :initialize_cache, group: :all do
62
+ cache_format_version = config.active_support.delete(:cache_format_version)
63
+ ActiveSupport.cache_format_version = cache_format_version if cache_format_version
64
+
62
65
  unless Rails.cache
63
66
  Rails.cache = ActiveSupport::Cache.lookup_store(*config.cache_store)
64
67
 
@@ -334,8 +334,14 @@ module Rails
334
334
  config = if yaml&.exist?
335
335
  loaded_yaml = ActiveSupport::ConfigurationFile.parse(yaml)
336
336
  if (shared = loaded_yaml.delete("shared"))
337
- loaded_yaml.each do |_k, values|
338
- values.reverse_merge!(shared)
337
+ loaded_yaml.each do |env, config|
338
+ if config.is_a?(Hash) && config.values.all?(Hash)
339
+ config.map do |name, sub_config|
340
+ sub_config.reverse_merge!(shared)
341
+ end
342
+ else
343
+ config.reverse_merge!(shared)
344
+ end
339
345
  end
340
346
  end
341
347
  Hash.new(shared).merge(loaded_yaml)
@@ -81,6 +81,21 @@ module Rails
81
81
  middleware.use ::Rack::ETag, "no-cache"
82
82
 
83
83
  middleware.use ::Rack::TempfileReaper unless config.api_only
84
+
85
+ if config.respond_to?(:active_record)
86
+ if selector_options = config.active_record.database_selector
87
+ resolver = config.active_record.database_resolver
88
+ context = config.active_record.database_resolver_context
89
+
90
+ middleware.use ::ActiveRecord::Middleware::DatabaseSelector, resolver, context, selector_options
91
+ end
92
+
93
+ if shard_resolver = config.active_record.shard_resolver
94
+ options = config.active_record.shard_selector || {}
95
+
96
+ middleware.use ::ActiveRecord::Middleware::ShardSelector, shard_resolver, options
97
+ end
98
+ end
84
99
  end
85
100
  end
86
101
 
@@ -87,21 +87,21 @@ module Rails
87
87
  ActiveSupport.run_load_hooks(:after_initialize, self)
88
88
  end
89
89
 
90
- class MutexHook
91
- def initialize(mutex = Mutex.new)
92
- @mutex = mutex
90
+ class MonitorHook # :nodoc:
91
+ def initialize(monitor = Monitor.new)
92
+ @monitor = monitor
93
93
  end
94
94
 
95
95
  def run
96
- @mutex.lock
96
+ @monitor.enter
97
97
  end
98
98
 
99
99
  def complete(_state)
100
- @mutex.unlock
100
+ @monitor.exit
101
101
  end
102
102
  end
103
103
 
104
- module InterlockHook
104
+ module InterlockHook # :nodoc:
105
105
  def self.run
106
106
  ActiveSupport::Dependencies.interlock.start_running
107
107
  end
@@ -116,7 +116,7 @@ module Rails
116
116
  # User has explicitly opted out of concurrent request
117
117
  # handling: presumably their code is not threadsafe
118
118
 
119
- app.executor.register_hook(MutexHook.new, outer: true)
119
+ app.executor.register_hook(MonitorHook.new, outer: true)
120
120
 
121
121
  elsif config.allow_concurrency == :unsafe
122
122
  # Do nothing, even if we know this is dangerous. This is the
@@ -263,8 +263,13 @@ module Rails
263
263
  MSG
264
264
  else
265
265
  error = CorrectableError.new("Could not find server '#{server}'.", server, RACK_SERVERS)
266
+ if error.respond_to?(:detailed_message)
267
+ formatted_message = error.detailed_message
268
+ else
269
+ formatted_message = error.message
270
+ end
266
271
  <<~MSG
267
- #{error.message}
272
+ #{formatted_message}
268
273
  Run `bin/rails server --help` for more options.
269
274
  MSG
270
275
  end
@@ -9,8 +9,8 @@ module Rails
9
9
  module VERSION
10
10
  MAJOR = 7
11
11
  MINOR = 0
12
- TINY = 3
13
- PRE = "1"
12
+ TINY = 4
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -187,12 +187,12 @@ module Rails
187
187
  [
188
188
  options.values_at(
189
189
  :skip_active_record,
190
- :skip_action_mailer,
191
190
  :skip_test,
192
191
  :skip_action_cable,
193
192
  :skip_active_job
194
193
  ),
195
194
  skip_active_storage?,
195
+ skip_action_mailer?,
196
196
  skip_action_mailbox?,
197
197
  skip_action_text?
198
198
  ].flatten.none?
@@ -220,7 +220,11 @@ module Rails
220
220
  end
221
221
 
222
222
  def skip_active_storage? # :doc:
223
- options[:skip_active_storage] || options[:skip_active_record]
223
+ options[:skip_active_storage] || options[:skip_active_record] || options[:skip_active_job]
224
+ end
225
+
226
+ def skip_action_mailer? # :doc:
227
+ options[:skip_action_mailer] || options[:skip_active_job]
224
228
  end
225
229
 
226
230
  def skip_action_mailbox? # :doc:
@@ -34,13 +34,6 @@
34
34
  # implementation.
35
35
  # Rails.application.config.active_support.remove_deprecated_time_with_zone_name = true
36
36
 
37
- # Change the format of the cache entry.
38
- # Changing this default means that all new cache entries added to the cache
39
- # will have a different format that is not supported by Rails 6.1 applications.
40
- # Only change this value after your application is fully deployed to Rails 7.0
41
- # and you have no plans to rollback.
42
- # Rails.application.config.active_support.cache_format_version = 7.0
43
-
44
37
  # Calls `Rails.application.executor.wrap` around test cases.
45
38
  # This makes test cases behave closer to an actual request or job.
46
39
  # Several features that are normally disabled in test, such as Active Record query cache
@@ -71,7 +64,7 @@
71
64
  # This default means that all columns will be referenced in INSERT queries
72
65
  # regardless of whether they have a default or not.
73
66
  # Rails.application.config.active_record.partial_inserts = false
74
- #
67
+
75
68
  # Protect from open redirect attacks in `redirect_back_or_to` and `redirect_to`.
76
69
  # Rails.application.config.action_controller.raise_on_open_redirects = true
77
70
 
@@ -82,18 +75,6 @@
82
75
  # The `:mini_magick` option is not deprecated; it's fine to keep using it.
83
76
  # Rails.application.config.active_storage.variant_processor = :vips
84
77
 
85
- # If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer
86
- # was `:marshal`. Convert all cookies to JSON, using the `:hybrid` formatter.
87
- #
88
- # If you're confident all your cookies are JSON formatted, you can switch to the `:json` formatter.
89
- #
90
- # Continue to use `:marshal` for backward-compatibility with old cookies.
91
- #
92
- # If you have configured the serializer elsewhere, you can remove this.
93
- #
94
- # See https://guides.rubyonrails.org/action_controller_overview.html#cookies for more information.
95
- # Rails.application.config.action_dispatch.cookies_serializer = :hybrid
96
-
97
78
  # Enable parameter wrapping for JSON.
98
79
  # Previously this was set in an initializer. It's fine to keep using that initializer if you've customized it.
99
80
  # To disable parameter wrapping entirely, set this config to `false`.
@@ -115,3 +96,40 @@
115
96
  # "X-Permitted-Cross-Domain-Policies" => "none",
116
97
  # "Referrer-Policy" => "strict-origin-when-cross-origin"
117
98
  # }
99
+
100
+
101
+ # ** Please read carefully, this must be configured in config/application.rb **
102
+ # Change the format of the cache entry.
103
+ # Changing this default means that all new cache entries added to the cache
104
+ # will have a different format that is not supported by Rails 6.1 applications.
105
+ # Only change this value after your application is fully deployed to Rails 7.0
106
+ # and you have no plans to rollback.
107
+ # When you're ready to change format, add this to `config/application.rb` (NOT this file):
108
+ # config.active_support.cache_format_version = 7.0
109
+
110
+
111
+ # Cookie serializer: 2 options
112
+ #
113
+ # If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer
114
+ # is `:marshal`. The default for new apps is `:json`.
115
+ #
116
+ # Rails.application.config.action_dispatch.cookies_serializer = :json
117
+ #
118
+ #
119
+ # To migrate an existing application to the `:json` serializer, use the `:hybrid` option.
120
+ #
121
+ # Rails transparently deserializes existing (Marshal-serialized) cookies on read and
122
+ # re-writes them in the JSON format.
123
+ #
124
+ # It is fine to use `:hybrid` long term; you should do that until you're confident *all* your cookies
125
+ # have been converted to JSON. To keep using `:hybrid` long term, move this config to its own
126
+ # initializer or to `config/application.rb`.
127
+ #
128
+ # Rails.application.config.action_dispatch.cookies_serializer = :hybrid
129
+ #
130
+ #
131
+ # If your cookies can't yet be serialized to JSON, keep using `:marshal` for backward-compatibility.
132
+ #
133
+ # If you have configured the serializer elsewhere, you can remove this section of the file.
134
+ #
135
+ # See https://guides.rubyonrails.org/action_controller_overview.html#cookies for more information.
@@ -266,8 +266,14 @@ module Rails
266
266
  options = sorted_groups.flat_map(&:last)
267
267
  error = Command::Base::CorrectableError.new("Could not find generator '#{namespace}'.", namespace, options)
268
268
 
269
+ if error.respond_to?(:detailed_message)
270
+ formatted_message = error.detailed_message
271
+ else
272
+ formatted_message = error.message
273
+ end
274
+
269
275
  puts <<~MSG
270
- #{error.message}
276
+ #{formatted_message}
271
277
  Run `bin/rails generate --help` for more options.
272
278
  MSG
273
279
  end
data/lib/rails/railtie.rb CHANGED
@@ -249,6 +249,10 @@ module Rails
249
249
  end
250
250
  end
251
251
 
252
+ def inspect # :nodoc:
253
+ "#<#{self.class.name}>"
254
+ end
255
+
252
256
  def configure(&block) # :nodoc:
253
257
  instance_eval(&block)
254
258
  end
data/lib/rails.rb CHANGED
@@ -80,6 +80,13 @@ module Rails
80
80
  @_env = ActiveSupport::EnvironmentInquirer.new(environment)
81
81
  end
82
82
 
83
+ # Returns the ActiveSupport::ErrorReporter of the current Rails project,
84
+ # otherwise it returns +nil+ if there is no project.
85
+ #
86
+ # Rails.error.handle(IOError) do
87
+ # # ...
88
+ # end
89
+ # Rails.error.report(error)
83
90
  def error
84
91
  application && application.executor.error_reporter
85
92
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railties
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.3.1
4
+ version: 7.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-12 00:00:00.000000000 Z
11
+ date: 2022-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 7.0.3.1
19
+ version: 7.0.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 7.0.3.1
26
+ version: 7.0.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actionpack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 7.0.3.1
33
+ version: 7.0.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 7.0.3.1
40
+ version: 7.0.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 7.0.3.1
103
+ version: 7.0.4
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 7.0.3.1
110
+ version: 7.0.4
111
111
  description: 'Rails internals: application bootup, plugins, generators, and rake tasks.'
112
112
  email: david@loudthinking.com
113
113
  executables:
@@ -422,10 +422,10 @@ licenses:
422
422
  - MIT
423
423
  metadata:
424
424
  bug_tracker_uri: https://github.com/rails/rails/issues
425
- changelog_uri: https://github.com/rails/rails/blob/v7.0.3.1/railties/CHANGELOG.md
426
- documentation_uri: https://api.rubyonrails.org/v7.0.3.1/
425
+ changelog_uri: https://github.com/rails/rails/blob/v7.0.4/railties/CHANGELOG.md
426
+ documentation_uri: https://api.rubyonrails.org/v7.0.4/
427
427
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
428
- source_code_uri: https://github.com/rails/rails/tree/v7.0.3.1/railties
428
+ source_code_uri: https://github.com/rails/rails/tree/v7.0.4/railties
429
429
  rubygems_mfa_required: 'true'
430
430
  post_install_message:
431
431
  rdoc_options: