From 78842f56a3be7f4e63e426665edd85dd135f1b97 Mon Sep 17 00:00:00 2001 From: GregM Date: Tue, 7 Mar 2023 15:27:37 +0100 Subject: [PATCH] fix invalid argument for foreach --- 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 5f0741b26d4..cb3af5db5e3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6090,13 +6090,15 @@ abstract class CommonObject // If field is a computed field, value must become result of compute (regardless of whether a row exists // in the element's extrafields table) - foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { - if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) { - //var_dump($conf->disable_compute); - if (empty($conf->disable_compute)) { - global $objectoffield; // We set a global variable to $objectoffield so - $objectoffield = $this; // we can use it inside computed formula - $this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, ''); + if (is_array($extrafields->attributes[$this->table_element]['label'])){ + foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { + if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) { + //var_dump($conf->disable_compute); + if (empty($conf->disable_compute)) { + global $objectoffield; // We set a global variable to $objectoffield so + $objectoffield = $this; // we can use it inside computed formula + $this->array_options['options_' . $key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, ''); + } } } }