8000 chore: Port forward of #7910 by fsbraun · Pull Request #7911 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

chore: Port forward of #7910 #7911

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

Merged
merged 2 commits into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cms/cache/placeholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ def _get_placeholder_cache_key(placeholder, lang, site_id, request, soft=False):
if sub_key_list:
cache_key += '|' + '|'.join(sub_key_list)

if len(cache_key) > 250:
# django itse 5648 lf adds "version" add the end of cache-keys, e.g. "<key>:1".
# -> If `cache.set()` is for example called with `version=""`, it still adds
# `:` at the end. So if we check the length for `> 250`, a length of 249
# or even 250 ends up in an InvalidCacheKey-exception.
# In order to avoid these errors, we hash the keys at a lower length to also
# have a little buffer.
if len(cache_key) > 200:
cache_key = '{prefix}|{hash}'.format(
prefix=prefix,
hash=hashlib.sha1(cache_key.encode('utf-8')).hexdigest(),
Expand Down
0