Skip to content

Commit 614fc3d

Browse files
committed
Delay the exclusion of the configs to the last minute
The framework still rely on the configuration object being modified in initializers, so we need to delay the exclusion to the last minute.
1 parent 3ca36fb commit 614fc3d

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

actionpack/lib/action_controller/railtie.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@ class Railtie < Rails::Railtie # :nodoc:
5757
options.asset_host ||= app.config.asset_host
5858
options.relative_url_root ||= app.config.relative_url_root
5959

60-
# Configs used in other initializers
61-
options = options.except(
62-
:log_query_tags_around_actions,
63-
:permit_all_parameters,
64-
:action_on_unpermitted_parameters,
65-
:always_permitted_parameters
66-
)
67-
6860
ActiveSupport.on_load(:action_controller) do
6961
include app.routes.mounted_helpers
7062
extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
7163
extend ::ActionController::Railties::Helpers
7264

65+
# Configs used in other initializers
66+
options = options.except(
67+
:log_query_tags_around_actions,
68+
:permit_all_parameters,
69+
:action_on_unpermitted_parameters,
70+
:always_permitted_parameters
71+
)
72+
7373
options.each do |k, v|
7474
k = "#{k}="
7575
if respond_to?(k)

activejob/lib/active_job/railtie.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ class Railtie < Rails::Railtie # :nodoc:
2525
options = app.config.active_job
2626
options.queue_adapter ||= :async
2727

28-
# Configs used in other initializers
29-
options = options.except(
30-
:log_query_tags_around_perform,
31-
:custom_serializers
32-
)
33-
3428
ActiveSupport.on_load(:active_job) do
29+
# Configs used in other initializers
30+
options = options.except(
31+
:log_query_tags_around_perform,
32+
:custom_serializers
33+
)
34+
3535
options.each do |k, v|
3636
k = "#{k}="
3737
send(k, v) if respond_to? k

activerecord/lib/active_record/railtie.rb

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ class Railtie < Rails::Railtie # :nodoc:
8787
end
8888

8989
initializer "active_record.migration_error" do |app|
90-
if config.active_record.delete(:migration_error) == :page_load
90+
if config.active_record.migration_error == :page_load
9191
config.app_middleware.insert_after ::ActionDispatch::Callbacks,
9292
ActiveRecord::Migration::CheckPending,
9393
file_watcher: app.config.file_watcher
9494
end
9595
end
9696

9797
initializer "active_record.database_selector" do
98-
if options = config.active_record.delete(:database_selector)
99-
resolver = config.active_record.delete(:database_resolver)
100-
operations = config.active_record.delete(:database_resolver_context)
98+
if options = config.active_record.database_selector
99+
resolver = config.active_record.database_resolver
100+
operations = config.active_record.database_resolver_context
101101
config.app_middleware.use ActiveRecord::Middleware::DatabaseSelector, resolver, operations, options
102102
end
103103
end
@@ -128,9 +128,9 @@ class Railtie < Rails::Railtie # :nodoc:
128128
end
129129

130130
initializer "active_record.check_schema_cache_dump" do
131-
check_schema_cache_dump_version = config.active_record.delete(:check_schema_cache_dump_version)
131+
check_schema_cache_dump_version = config.active_record.check_schema_cache_dump_version
132132

133-
if config.active_record.delete(:use_schema_cache_dump)
133+
if config.active_record.use_schema_cache_dump
134134
config.after_initialize do |app|
135135
ActiveSupport.on_load(:active_record) do
136136
db_config = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env).first
@@ -205,15 +205,15 @@ class Railtie < Rails::Railtie # :nodoc:
205205
SQLITE3_PRODUCTION_WARN = "You are running SQLite in production, this is generally not recommended."\
206206
" You can disable this warning by setting \"config.active_record.sqlite3_production_warning=false\"."
207207
initializer "active_record.sqlite3_production_warning" do
208-
if config.active_record.delete(:sqlite3_production_warning) && Rails.env.production?
208+
if config.active_record.sqlite3_production_warning && Rails.env.production?
209209
ActiveSupport.on_load(:active_record_sqlite3adapter) do
210210
Rails.logger.warn(SQLITE3_PRODUCTION_WARN)
211211
end
212212
end
213213
end
214214

215215
initializer "active_record.set_configs" do |app|
216-
configs = app.config.active_record.except(:query_log_tags_enabled, :query_log_tags, :cache_query_log_tags)
216+
configs = app.config.active_record
217217

218218
config.after_initialize do
219219
configs.each do |k, v|
@@ -226,6 +226,20 @@ class Railtie < Rails::Railtie # :nodoc:
226226
end
227227

228228
ActiveSupport.on_load(:active_record) do
229+
# Configs used in other initializers
230+
configs = configs.except(
231+
:migration_error,
232+
:database_selector,
233+
:database_resolver,
234+
:database_resolver_context,
235+
:query_log_tags_enabled,
236+
:query_log_tags,
237+
:cache_query_log_tags,
238+
:sqlite3_production_warning,
239+
:check_schema_cache_dump_version,
240+
:use_schema_cache_dump
241+
)
242+
229243
configs.each do |k, v|
230244
next if k == :encryption
231245
setter = "#{k}="

0 commit comments

Comments
 (0)