Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
settings: Refetch realm and user profile objects.
Sahil Batraa0efc0ee76ba
diff --git a/zerver/views/realm.py b/zerver/views/realm.pyindex e51049d803c..595bad9c749 100644--- a/zerver/views/realm.py+++ b/zerver/views/realm.py@@ -177,7 +177,14 @@ def update_realm(Json[int] | None, ApiParamConfig("can_access_all_users_group")] = None,) -> HttpResponse:- realm = user_profile.realm+ # Realm object is being refetched here to make sure that we+ # do not use stale object from cache which can happen when a+ # previous request tried updating multiple settings in a single+ # request.+ #+ # TODO: Change the cache flushing strategy to make sure cache+ # does not contain stale objects.+ realm = Realm.objects.get(id=user_profile.realm_id)# Additional validation/error checking beyond types go here, so# the entire request can succeed or fail atomically.diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.pyindex 6fb2ba14d91..508b7ce7eb9 100644--- a/zerver/views/user_settings.py+++ b/zerver/views/user_settings.py@@ -305,6 +305,14 @@ def json_change_settings(),web_navigate_to_sent_message: bool | None = REQ(json_validator=check_bool, default=None),) -> HttpResponse:+ # UserProfile object is being refetched here to make sure that we+ # do not use stale object from cache which can happen when a+ # previous request tried updating multiple settings in a single+ # request.+ #+ # TODO: Change the cache flushing strategy to make sure cache+ # does not contain stale objects.+ user_profile = UserProfile.objects.get(id=user_profile.id)if (default_language is not Noneor notification_sound is not None