Skip to content
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

Handle nil key for MemCacheStore#normalize_key #41376

Merged
merged 1 commit into from Feb 9, 2021

Conversation

fatkodima
Copy link
Member

Closes #41352

There is already an existing test case for this

def test_read_multi_with_empty_keys_and_a_logger_and_no_namespace
@cache.options[:namespace] = nil
@cache.logger = ActiveSupport::Logger.new(nil)
assert_equal({}, @cache.read_multi)
end

But it passed for memcached because of @store.silence! and the relevant branch with a bug was skipped.

@rafaelfranca rafaelfranca merged commit fc54468 into rails:main Feb 9, 2021
rafaelfranca added a commit that referenced this pull request Feb 9, 2021
Handle nil key for MemCacheStore#normalize_key
if key
key = key.dup.force_encoding(Encoding::ASCII_8BIT)
key = key.gsub(ESCAPE_KEY_CHARS) { |match| "%#{match.getbyte(0).to_s(16).upcase}" }
key = "#{key[0, 213]}:md5:#{ActiveSupport::Digest.hexdigest(key)}" if key.size > 250
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you change here the key format back to md5. Next time please make sure the patch is up-to-date

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Sorry 💦

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