Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
custom_profile_fields: Make transaction no longer durable.
Mateusz Mandera3ccd53ce20c7
diff --git a/zerver/actions/custom_profile_fields.py b/zerver/actions/custom_profile_fields.pyindex 34db9d869a1..d26a5426d1e 100644--- a/zerver/actions/custom_profile_fields.py+++ b/zerver/actions/custom_profile_fields.py@@ -169,7 +169,7 @@ def notify_user_update_custom_profile_data(send_event_on_commit(user_profile.realm, event, get_user_ids_who_can_access_user(user_profile))[email protected](durable=True)[email protected](savepoint=False)def do_update_user_custom_profile_data_if_changed(user_profile: UserProfile,data: list[ProfileDataElementUpdateDict],@@ -210,7 +210,7 @@ def do_update_user_custom_profile_data_if_changed()[email protected](durable=True)[email protected](savepoint=False)def check_remove_custom_profile_field_value(user_profile: UserProfile, field_id: int, acting_user: UserProfile) -> None:diff --git a/zerver/views/custom_profile_fields.py b/zerver/views/custom_profile_fields.pyindex 68d3c552905..f8b3d62b526 100644--- a/zerver/views/custom_profile_fields.py+++ b/zerver/views/custom_profile_fields.py@@ -2,7 +2,7 @@ from typing import Annotatedimport orjsonfrom django.core.exceptions import ValidationError-from django.db import IntegrityError+from django.db import IntegrityError, transactionfrom django.http import HttpRequest, HttpResponsefrom django.utils.translation import gettext as _from pydantic import Json, StringConstraints@@ -307,8 +307,11 @@ def remove_user_custom_profile_data(*,data: Json[list[int]],) -> HttpResponse:- for field_id in data:- check_remove_custom_profile_field_value(user_profile, field_id, acting_user=user_profile)+ with transaction.atomic(durable=True):+ for field_id in data:+ check_remove_custom_profile_field_value(+ user_profile, field_id, acting_user=user_profile+ )return json_success(request)@@ -321,6 +324,7 @@ def update_user_custom_profile_data(data: Json[list[ProfileDataElementUpdateDict]],) -> HttpResponse:validate_user_custom_profile_data(user_profile.realm.id, data, acting_user=user_profile)- do_update_user_custom_profile_data_if_changed(user_profile, data)+ with transaction.atomic(durable=True):+ do_update_user_custom_profile_data_if_changed(user_profile, data)# We need to call this explicitly otherwise constraints are not checkreturn json_success(request)diff --git a/zerver/views/users.py b/zerver/views/users.pyindex 79696aa933d..ce69de8feba 100644--- a/zerver/views/users.py+++ b/zerver/views/users.py@@ -5,6 +5,7 @@ from typing import Annotated, Any, TypeAliasfrom django.conf import settingsfrom django.contrib.auth.models import AnonymousUserfrom django.core.files.uploadedfile import UploadedFile+from django.db import transactionfrom django.http import HttpRequest, HttpResponsefrom django.shortcuts import redirectfrom django.utils.translation import gettext as _@@ -197,6 +198,7 @@ class ProfileDataElement(BaseModel):@typed_endpoint[email protected](durable=True)def update_user_backend(request: HttpRequest,user_profile: UserProfile,