From d200dea90535876342871bdf9ecb92db4ae81aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Wed, 24 May 2023 11:26:55 +0200 Subject: [PATCH 1/2] FIX: default values were not set for specimen objects --- htdocs/core/class/commonobject.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ed74194d492..a2bf74d82e0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9452,6 +9452,18 @@ abstract class CommonObject $this->{$key} = $value; } } + + foreach ($this->fields as $key => $value) { + // If fields are already set, do nothing + if (array_key_exists($key, $fields)) { + continue; + } + + if (!empty($value['default'])) { + $this->{$key} = $value['default']; + } + } + return 1; } From 9b8e56418780baae1d5ce5953ffda16e091c2a09 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 May 2023 14:07:24 +0200 Subject: [PATCH 2/2] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a2bf74d82e0..46563688d72 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9453,6 +9453,7 @@ abstract class CommonObject } } + // Force values to default values when known foreach ($this->fields as $key => $value) { // If fields are already set, do nothing if (array_key_exists($key, $fields)) { @@ -9460,7 +9461,7 @@ abstract class CommonObject } if (!empty($value['default'])) { - $this->{$key} = $value['default']; + $this->$key = $value['default']; } }