Merge pull request #48604 from skipkayhil/hm-ensure-cache-format-deprecated

Emit warning when using 6.1 cache format as well
This commit is contained in:
Guillermo Iguaran 2023-06-28 18:58:23 -07:00 committed by GitHub
commit de29ff225e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 8 deletions

@ -105,14 +105,6 @@ def self.cache_format_version
end
def self.cache_format_version=(value)
if value == 6.1
ActiveSupport.deprecator.warn <<~EOM
Support for `config.active_support.cache_format_version = 6.1` has been deprecated and will be removed in Rails 7.2.
Check the Rails upgrade guide at https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#new-activesupport-cache-serialization-format
for more information on how to upgrade.
EOM
end
Cache.format_version = value
end

@ -671,6 +671,12 @@ def clear(options = nil)
def default_coder
case Cache.format_version
when 6.1
ActiveSupport.deprecator.warn <<~EOM
Support for `config.active_support.cache_format_version = 6.1` has been deprecated and will be removed in Rails 7.2.
Check the Rails upgrade guide at https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#new-activesupport-cache-serialization-format
for more information on how to upgrade.
EOM
Cache::SerializerWithFallback[:marshal_6_1]
when 7.0
Cache::SerializerWithFallback[:marshal_7_0]

@ -4246,6 +4246,18 @@ def new(app); self; end
Rails.cache.instance_variable_get(:@coder)
end
test "ActiveSupport::Cache.format_version 6.1 is deprecated" do
remove_from_config '.*config\.load_defaults.*\n'
app "development"
assert_equal 6.1, ActiveSupport::Cache.format_version
assert_deprecated(ActiveSupport.deprecator) do
ActiveSupport::Cache::Store.new
end
end
test "raise_on_invalid_cache_expiration_time is false with 7.0 defaults" do
remove_from_config '.*config\.load_defaults.*\n'
add_to_config 'config.load_defaults "7.0"'