From 9bf8103dad76fc628e836f4c95bbe284ada7db29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 21 Apr 2026 11:47:12 +0200 Subject: [PATCH] clean code (#37947) * fix categories translations * fix categories translations * fix categories translations * fix categories translations * Update traduction.php * Update traduction.php * Update photos.php * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix categories translations * fix * fix * fix --------- Co-authored-by: Laurent Destailleur --- htdocs/core/class/commonobject.class.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 16e78a972f5..f41bc0c7bfc 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6957,7 +6957,7 @@ abstract class CommonObject */ public function insertExtraFields($trigger = '', $userused = null) { - global $langs, $user; + global $langs, $extrafields, $user; if (getDolGlobalString('MAIN_EXTRAFIELDS_DISABLED') || empty($this->array_options)) { return 0; @@ -6971,8 +6971,10 @@ abstract class CommonObject // Check parameters $langs->load('admin'); - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); + if (!isset($extrafields) || !is_object($extrafields)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + } $target_extrafields = $extrafields->fetch_name_optionals_label($this->table_element); // Eliminate copied source object extra fields that do not exist in target object @@ -7436,7 +7438,7 @@ abstract class CommonObject */ public function updateExtraField($key, $trigger = null, $userused = null) { - global $langs, $user, $hookmanager; + global $langs, $user, $extrafields, $hookmanager; if (getDolGlobalString('MAIN_EXTRAFIELDS_DISABLED')) { return 0; @@ -7451,8 +7453,10 @@ abstract class CommonObject if (!empty($this->array_options) && isset($this->array_options["options_".$key])) { // Check parameters $langs->load('admin'); - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); + if (!isset($extrafields) || !is_object($extrafields)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + } $extrafields->fetch_name_optionals_label($this->table_element); $value = $this->array_options["options_".$key];