From 6985e366c24268243bec49543e4b97e1b9d6ec5f Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Fri, 7 Feb 2025 10:58:13 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B08139=20-=20Avoid=20double=20writing=20in?= =?UTF-8?q?=20lifecycle=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/dbobject.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 7c8e8e515..1dbffce8d 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -4556,7 +4556,7 @@ abstract class DBObject implements iDisplay $bSuccess = true; // Prevent current object from being updated by the actions $this->AddCurrentObjectInCrudStack('APPLY_STIMULUS'); - MetaModel::StartReentranceProtection($this); + $bIsNewlyProtected = MetaModel::StartReentranceProtection($this); try { foreach ($aTransitionDef['actions'] as $actionHandler) { if (is_string($actionHandler)) { @@ -4610,7 +4610,10 @@ abstract class DBObject implements iDisplay } } } finally { - MetaModel::StopReentranceProtection($this); + if ($bIsNewlyProtected) { + // Stops protection only if the object was not already protected + MetaModel::StopReentranceProtection($this); + } $this->RemoveCurrentObjectInCrudStack(); } if ($bSuccess)