Skip to content

Reverted String Class .to_a monkey patch #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

haadfida
Copy link

@haadfida haadfida commented Feb 8, 2022

.to_a method has been removed from the String class since Ruby 1.9 reference: https://stackoverflow.com/a/4465629/12131035
Rails caching code works with the assumption that .to_a can not be called on strings.

The following snippet below in the file Activesupport-6.0.3.2/lib/active_support/cache.rb, ends up in infinite recursion is .to_a method is called on Strings.

def expanded_version(key)
case
when key.respond_to?(:cache_version) then key.cache_version.to_param
when key.is_a?(Array) then key.map { |element| expanded_version(element) }.compact.to_param
when key.respond_to?(:to_a) then expanded_version(key.to_a)
end
end

This change is needed to ensure that rails and ruby code works as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant