From cbfe735c69a37446d0c5a9d448ad6d181abd1736 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 14 Apr 2022 22:31:26 +0200 Subject: [PATCH] Deprecate config.enable_dependency_loading --- guides/source/configuring.md | 4 ---- railties/CHANGELOG.md | 4 ++++ .../lib/rails/application/configuration.rb | 18 +++++++++++++++++- .../test/application/configuration_test.rb | 7 +++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 872881524b762..1b3cc7cfb8995 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -233,10 +233,6 @@ Registers namespaces that are eager loaded when `config.eager_load` is set to `t Accepts an array of paths from which Rails will eager load on boot if `config.eager_load` is true. Defaults to every folder in the `app` directory of the application. -#### `config.enable_dependency_loading` - -When `true`, enables autoloading, even if the application is eager loaded and `config.enable_reloading` is set to `false`. Defaults to `false`. - #### `config.encoding` Sets up the application-wide encoding. Defaults to UTF-8. diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 5e898223eb035..e9e75a5c43c03 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Deprecate `config.enable_dependency_loading`. This flag addressed a limitation of the `classic` autoloader and has no effect nowadays. To fix this deprecation, please just delete the reference. + + *Xavier Noria* + * Define `config.enable_reloading` to be `!config.cache_classes` for a more intuitive name. While `config.enable_reloading` and `config.reloading_enabled?` are preferred from now on, `config.cache_classes` is supported for backwards compatibility. *Xavier Noria* diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 8df587dbff7fb..843ebe6238eef 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -17,7 +17,7 @@ class Configuration < ::Rails::Engine::Configuration :log_tags, :railties_order, :relative_url_root, :secret_key_base, :ssl_options, :public_file_server, :session_options, :time_zone, :reload_classes_only_on_change, - :beginning_of_week, :filter_redirect, :x, :enable_dependency_loading, + :beginning_of_week, :filter_redirect, :x, :read_encrypted_secrets, :log_level, :content_security_policy_report_only, :content_security_policy_nonce_generator, :content_security_policy_nonce_directives, :require_master_key, :credentials, :disable_sandbox, :add_autoload_paths_to_load_path, @@ -297,6 +297,22 @@ def enable_reloading=(value) self.cache_classes = !value end + ENABLE_DEPENDENCY_LOADING_WARNING = <<~MSG + This flag addressed a limitation of the `classic` autoloader and has no effect nowadays. + To fix this deprecation, please just delete the reference. + MSG + private_constant :ENABLE_DEPENDENCY_LOADING_WARNING + + def enable_dependency_loading + ActiveSupport::Deprecation.warn(ENABLE_DEPENDENCY_LOADING_WARNING) + @enable_dependency_loading + end + + def enable_dependency_loading=(value) + ActiveSupport::Deprecation.warn(ENABLE_DEPENDENCY_LOADING_WARNING) + @enable_dependency_loading = value + end + def encoding=(value) @encoding = value silence_warnings do diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 5ee8593c610c5..627aaba3a7bc9 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -1343,6 +1343,13 @@ def index assert_equal false, ActionView::Resolver.caching? end + test "config.enable_dependency_loading is deprecated" do + app "development" + + assert_deprecated { Rails.application.config.enable_dependency_loading } + assert_deprecated { Rails.application.config.enable_dependency_loading = true } + end + test "ActionController::Base.raise_on_open_redirects is true by default for new apps" do app "development"