Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

cache: Decline to store querysets, with an error.

Alex Vandiver8f6f38c97c2c
diff --git a/zerver/lib/cache.py b/zerver/lib/cache.py
index b05e2b3fa5a..56dd6673f32 100644
--- a/zerver/lib/cache.py
+++ b/zerver/lib/cache.py
@@ -170,13 +170,12 @@ def cache_with_key(
val = func(*args, **kwargs)
if isinstance(val, QuerySet): # type: ignore[misc] # https://github.com/typeddjango/django-stubs/issues/704
- logging.warning(
- "cache_with_key attempted to store a full QuerySet object -- flattening using list()",
+ logging.error(
+ "cache_with_key attempted to store a full QuerySet object -- declining to cache",
stack_info=True,
)
- val = list(val)
-
- cache_set(key, val, cache_name=cache_name, timeout=timeout)
+ else:
+ cache_set(key, val, cache_name=cache_name, timeout=timeout)
return val