From 9484a03cef8b78221c08814e93cdbd0fcdaa7653 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Tue, 22 Oct 2024 11:29:08 +0200 Subject: [PATCH 1/2] Remove date_mod event if there are multiple ocurrences closes #18112 --- src/CommonDBTM.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CommonDBTM.php b/src/CommonDBTM.php index 8abd237e6d4..7e9c80977d5 100644 --- a/src/CommonDBTM.php +++ b/src/CommonDBTM.php @@ -1851,9 +1851,9 @@ protected function manageLocks() && (!isset($this->input['is_dynamic']) || $this->input['is_dynamic'] == false) ) { $fields = array_values($this->updates); - $idx = array_search('date_mod', $fields); - if ($idx !== false) { - unset($fields[$idx]); + $idx = array_keys($fields, 'date_mod'); + foreach ($idx as $i) { + unset($fields[$i]); } $stmt = $DB->prepare( $DB->buildInsert( From cc3a78e4887faa401033570a29fc69613fbc5bd9 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Tue, 22 Oct 2024 11:39:52 +0200 Subject: [PATCH 2/2] Update src/CommonDBTM.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cédric Anne --- src/CommonDBTM.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/CommonDBTM.php b/src/CommonDBTM.php index 7e9c80977d5..26eceaf6757 100644 --- a/src/CommonDBTM.php +++ b/src/CommonDBTM.php @@ -1851,10 +1851,7 @@ protected function manageLocks() && (!isset($this->input['is_dynamic']) || $this->input['is_dynamic'] == false) ) { $fields = array_values($this->updates); - $idx = array_keys($fields, 'date_mod'); - foreach ($idx as $i) { - unset($fields[$i]); - } + $fields = array_filter($fields, fn($f) => $f !== 'date_mod'); $stmt = $DB->prepare( $DB->buildInsert( $lockedfield->getTable(),