From c7d2a661bf451a416b2582ce562893f313e42e8f Mon Sep 17 00:00:00 2001 From: Lucky <93642903+LuckyRoussel98@users.noreply.github.com> Date: Thu, 30 Jul 2026 13:59:04 +0300 Subject: [PATCH] fix PHP Warnings (#39316) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commonobject.class.php:9398 — Undefined array key "options_pos": direct access to $this->array_options[$ef_name] without checking its existence → added an isset() with fallback to an empty string. commonobject.class.php:9767 (getRights() method) — Undefined property: stdClass::$shipping: $user->rights->$element accessed without checking that the module has registered this property (e.g., shipping module not active for this user) → added an isset(), returns null otherwise. html.form.class.php:6088-6091 — Undefined array key "value": the $input array passed to formconfirm/multiSelect may not contain a value key for a checkbox field → added an isset($input['value']) on both conditions. html.form.class.php:6752 (method form_modes_reglement()) — Undefined array key 2 / access on null: $selected corresponds to a payment method not in the cache cache_types_paiements → add an isset(). supplier_proposal/index.php:362 — Undefined property: stdClass::$dfv: the SQL query in the block (line 316) does not select the field fin_validite/dfv (unlike comm/propal/index.php which selects p.fin_validite as dfv) — this field does not even exist in llx_supplier_proposal. In addition to the warning, this bug systematically displayed the "Delay" icon (PHP8 comparison '' < number always true) → addition of an isset($obj->dfv) which properly neutralizes the test as long as this field is not returned by the request. Co-authored-by: Sylvain Legrand --- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/class/html.form.class.php | 8 ++++---- htdocs/supplier_proposal/index.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5a668879cb2..056e6a26a93 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9354,7 +9354,7 @@ abstract class CommonObject // Otherwise, they would be empty after an update of the object. See also getOptionalsFromPost // TODO: We should not have this hidden field, and action='update' should be done only if field was POSTED by form. $ef_name = 'options_' . $key; - $ef_value = $this->array_options[$ef_name]; + $ef_value = isset($this->array_options[$ef_name]) ? $this->array_options[$ef_name] : ''; $out .= '' . "\n"; continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list and <> 4 = not visible at the creation } elseif ($mode == 'view' && empty($visibility)) { @@ -9723,7 +9723,7 @@ abstract class CommonObject return $user->hasRight($module, $element); } - return $user->rights->$element; + return isset($user->rights->$element) ? $user->rights->$element : null; } /** diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 43db189dd0a..7ffba0cbae5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6025,7 +6025,7 @@ class Form $moreattr = (!empty($input['moreattr']) ? ' ' . $input['moreattr'] : ''); $morecss = (!empty($input['morecss']) ? ' ' . $input['morecss'] : ''); - $more .= '' . "\n"; + $more .= '' . "\n"; // 'value' non fourni par tous les appelants } } } @@ -6077,10 +6077,10 @@ class Form $more .= '
'; $more .= '
'; $more .= 'load_cache_types_paiements(); - $out .= $this->cache_types_paiements[$selected]['label']; + $out .= isset($this->cache_types_paiements[$selected]['label']) ? $this->cache_types_paiements[$selected]['label'] : ''; } else { $out .= " "; } diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php index 0565fe64af2..03c6a73cc2e 100644 --- a/htdocs/supplier_proposal/index.php +++ b/htdocs/supplier_proposal/index.php @@ -359,7 +359,7 @@ if (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'l print $supplier_proposalstatic->getNomUrl(1); print ''; print ''; - if ($db->jdate($obj->dfv) < ($now - $conf->supplier_proposal->cloture->warning_delay)) { + if (isset($obj->dfv) && $db->jdate($obj->dfv) < ($now - $conf->supplier_proposal->cloture->warning_delay)) { print img_warning($langs->trans("Late")); } print '';