From 884ac621dedeb9bd853d3161b4b6fcd91c2c29b4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 May 2023 17:43:37 +0200 Subject: [PATCH] Fix php8 --- htdocs/core/class/commonobject.class.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b82970baa97..5c0139aeb8e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9738,14 +9738,16 @@ 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)) { - continue; - } + if (property_exists($this, 'fields')) { + 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']; + if (!empty($value['default'])) { + $this->$key = $value['default']; + } } }