From 61ece3d5c53b8ec8563b19656ab3332ee2cd4c7d Mon Sep 17 00:00:00 2001 From: minimexat Date: Sun, 8 Feb 2026 03:05:47 +0100 Subject: [PATCH 1/2] FIX Replace direct $_POST access with GETPOST() in origin/originid recovery paths (#37143) When a create action fails and rolls back, several list/card pages restore origin parameters by assigning $_POST values directly to $_GET. This causes 'undefined array key' warnings on PHP 8.1+ if the POST data is missing or malformed. Replace raw $_POST['origin'] with GETPOST('origin', 'alpha') and raw $_POST['originid'] with GETPOSTINT('originid') which safely handle missing parameters. Files fixed: - htdocs/expedition/list.php - htdocs/fourn/commande/list.php - htdocs/commande/list.php - htdocs/compta/facture/card.php - htdocs/reception/list.php These files had TODO-style comments ('Keep this ?', 'Keep GET and POST here ?') indicating the pattern was already questionable. Co-authored-by: f-hoedl --- htdocs/commande/list.php | 4 ++-- htdocs/compta/facture/card.php | 4 ++-- htdocs/expedition/list.php | 4 ++-- htdocs/fourn/commande/list.php | 4 ++-- htdocs/reception/list.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index d963a4c87aa..75104d8e0a1 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -820,8 +820,8 @@ if (empty($reshook)) { $db->rollback(); $action = 'create'; - $_GET["origin"] = $_POST["origin"]; // Keep GET and POST here ? - $_GET["originid"] = $_POST["originid"]; // Keep GET and POST here ? + $_GET["origin"] = GETPOST("origin", 'alpha'); + $_GET["originid"] = GETPOSTINT("originid"); if (!empty($errors)) { setEventMessages(null, $errors, 'errors'); } else { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c7baebb9cb2..342f7d9d36f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2296,8 +2296,8 @@ if (empty($reshook)) { } else { $db->rollback(); $action = 'create'; - $_GET["origin"] = $_POST["origin"]; // Keep GET and POST here ? - $_GET["originid"] = $_POST["originid"]; // Keep GET and POST here ? + $_GET["origin"] = GETPOST("origin", 'alpha'); + $_GET["originid"] = GETPOSTINT("originid"); setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && (GETPOST('alldate_start', 'alpha') || GETPOST('alldate_end', 'alpha')) && $usercancreate) { diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 7ce243f7d5e..6cc2e61fe7b 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -611,8 +611,8 @@ if (empty($reshook)) { $db->rollback(); $action = 'create'; - $_GET["origin"] = $_POST["origin"]; - $_GET["originid"] = $_POST["originid"]; + $_GET["origin"] = GETPOST("origin", 'alpha'); + $_GET["originid"] = GETPOSTINT("originid"); if (!empty($errors)) { setEventMessages(null, $errors, 'errors'); } else { diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 3568e39cb5b..23fc14c332c 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -790,8 +790,8 @@ if (empty($reshook)) { } else { $db->rollback(); $action = 'create'; - $_GET["origin"] = $_POST["origin"]; // Keep this ? - $_GET["originid"] = $_POST["originid"]; // Keep this ? + $_GET["origin"] = GETPOST("origin", 'alpha'); + $_GET["originid"] = GETPOSTINT("originid"); setEventMessages("Error", null, 'errors'); $error++; } diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index e15a108ad63..d839917e341 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -612,8 +612,8 @@ if (empty($reshook)) { $db->rollback(); $action = 'create'; - $_GET["origin"] = $_POST["origin"]; // Keep this ? - $_GET["originid"] = $_POST["originid"]; // Keep this ? + $_GET["origin"] = GETPOST("origin", 'alpha'); + $_GET["originid"] = GETPOSTINT("originid"); setEventMessages($object->error, $errors, 'errors'); $error++; } From 02d0b6524c841d3b3158eb6b1b4e85962789440e Mon Sep 17 00:00:00 2001 From: minimexat Date: Sun, 8 Feb 2026 03:06:36 +0100 Subject: [PATCH 2/2] FIX Add missing isset() check for $_GET['file'] in viewimage.php (#37141) On line 65, $_GET['file'] is accessed without isset() check inside the modulepart=='mycompany' condition. This causes an 'undefined array key' warning on PHP 8.1+ when modulepart is 'mycompany' but no file parameter is provided. Note: GETPOST() is intentionally not used here as it is not available before main.inc.php is loaded (see existing code comment). Co-authored-by: f-hoedl --- htdocs/viewimage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index cf31808ef44..bfb453f8473 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -62,7 +62,7 @@ if (isset($_GET["modulepart"])) { // Some value of modulepart can be used to get resources that are public so no login are required. // For logo of company (by definition, the company logo is public) - if ($_GET["modulepart"] == 'mycompany' && preg_match('/^\/?logos\//', $_GET['file'])) { + if ($_GET["modulepart"] == 'mycompany' && isset($_GET['file']) && preg_match('/^\/?logos\//', $_GET['file'])) { $needlogin = 0; } // For barcode live generation (barcode are just a graph of a value, so can be public)