Skip to content

Commit

Permalink
Deprecate config.enable_dependency_loading
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Apr 14, 2022
1 parent cdabe88 commit cbfe735
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
4 changes: 0 additions & 4 deletions guides/source/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions railties/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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*
Expand Down
18 changes: 17 additions & 1 deletion railties/lib/rails/application/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions railties/test/application/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit cbfe735

Please sign in to comment.