Silence a ROR 7.1 deprecation warning by using Rails.cache as the default cache, if its available #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR started from an investigation into a deprecation warning on a ROR 7.0 -> 7.1 upgrade. The specific error at the time was:
This is triggered by this line in lib/warden/cognito.rb:
Of course, nowhere here is
cache_format_version
explicitly set (nor should it be), but rather this is the default value in ActiveSupport.config.load_defaults 7.1
call in an app's config/application.rb file. I believe this is because theNullStore.new
call gets executed atrequire
time and thus before the Rails app config hooks start firing.Workarounds:
ActiveSupport.cache_format_version = XX
in warden-cognito's land, if Rails isn't defined. This seems bad because it might mess with an app's settings, and we don't really need to enforce a particular cache format here - that's not our job.Rails.cache
when Rails is defined.I opted for the 2nd option here since it seemed less intrusive and more in-line with what I'd expect in a Rails context. It also removed the deprecation in my original app.