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 <hoefla14@htl-kaindorf.ac.at>
This commit is contained in:
parent
9369f4aea3
commit
61ece3d5c5
5 changed files with 10 additions and 10 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue