From a9f08e87f97fdc3eb4b5c7fd523abf700c7fc5ab Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Tue, 21 Feb 2023 11:06:04 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B05906=20-=20CRUD=20Event=20-=20move=20som?= =?UTF-8?q?e=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/dbobject.class.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/dbobject.class.php b/core/dbobject.class.php index faed30457..9112ecef8 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -2986,11 +2986,7 @@ abstract class DBObject implements iDisplay // Ensure the update of the values (we are accessing the data directly) $this->DoComputeValues(); $this->OnInsert(); - if ($this->m_iKey < 0) { - // This was a temporary "memory" key: discard it so that DBInsertSingleTable will not try to use it! - $this->m_iKey = null; - $this->UpdateCurrentObjectInCrudStack(); - } + // If not automatically computed, then check that the key is given by the caller if (!MetaModel::IsAutoIncrementKey($sRootClass)) { if (empty($this->m_iKey)) { @@ -3006,6 +3002,7 @@ abstract class DBObject implements iDisplay if ($this->m_iKey < 0) { // This was a temporary "memory" key: discard it so that DBInsertSingleTable will not try to use it! $this->m_iKey = null; + $this->UpdateCurrentObjectInCrudStack(); } $this->ComputeStopWatchesDeadline(true);