From d5c61d07ba60cf90a434fcf35da3cb8eccf83216 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 23 Sep 2025 21:39:51 +0200 Subject: [PATCH 1/5] PHPStan > Update baseline (#35452) Co-authored-by: Dolibot --- dev/build/phpstan/phpstan-baseline.neon | 6 ------ 1 file changed, 6 deletions(-) diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index a825625573e..3dca13eb26f 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -3894,12 +3894,6 @@ parameters: count: 2 path: ../../../htdocs/compta/sociales/class/cchargesociales.class.php - - - message: '#^Property Cchargesociales\:\:\$fk_pays \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../../htdocs/compta/sociales/class/cchargesociales.class.php - - message: '#^Property Cchargesociales\:\:\$libelle \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property From 985b6f258a130386c449c31b3dc0c51d5516e42c Mon Sep 17 00:00:00 2001 From: kaantopkaya Date: Tue, 23 Sep 2025 21:41:32 +0200 Subject: [PATCH 2/5] new: add otherCurlOptions to getURLContent (#35454) --- htdocs/core/lib/geturl.lib.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 5a5c0241f79..fe5e660a2f3 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -42,9 +42,10 @@ * @param int<-1,1> $ssl_verifypeer -1=Auto (no ssl check on dev, check on prod), 0=No ssl check, 1=Always ssl check * @param int $timeoutconnect Timeout connect * @param int $timeoutresponse Timeout response + * @param array $otherCurlOptions Array of other curl options to set. Example: array(CURLOPT_SSL_VERIFYPEER => false) * @return array{http_code:int,content:string,curl_error_no:int,curl_error_msg:string} Returns an associative array containing the response from the server array('http_code'=>http response code, 'content'=>response, 'curl_error_no'=>errno, 'curl_error_msg'=>errmsg...) */ -function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = 1, $addheaders = array(), $allowedschemes = array('http', 'https'), $localurl = 0, $ssl_verifypeer = -1, $timeoutconnect = 0, $timeoutresponse = 0) +function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = 1, $addheaders = array(), $allowedschemes = array('http', 'https'), $localurl = 0, $ssl_verifypeer = -1, $timeoutconnect = 0, $timeoutresponse = 0, $otherCurlOptions = array()) { // Get global variables for proxy use $USE_PROXY = getDolGlobalInt('MAIN_PROXY_USE'); @@ -194,6 +195,12 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = } } + if (is_array($otherCurlOptions)) { + foreach ($otherCurlOptions as $option => $value) { + curl_setopt($ch, $option, $value); + } + } + $newUrl = $url; $maxRedirection = 5; $info = array(); From ca8a6c9c459c8986195085e8f95683fae933cf5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Sep 2025 21:42:20 +0200 Subject: [PATCH 3/5] clean code (#35447) * clean code * clean code * clean code --- dev/build/phpstan/phpstan-baseline.neon | 54 ------------------- .../class/accountancycategory.class.php | 20 +++---- 2 files changed, 10 insertions(+), 64 deletions(-) diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 3dca13eb26f..bb30e337558 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -156,60 +156,6 @@ parameters: count: 1 path: ../../../htdocs/accountancy/bookkeeping/export.php - - - message: '#^Property AccountancyCategory\:\:\$active \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/accountancy/class/accountancycategory.class.php - - - - message: '#^Property AccountancyCategory\:\:\$category_type \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/accountancy/class/accountancycategory.class.php - - - - message: '#^Property AccountancyCategory\:\:\$code \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/accountancy/class/accountancycategory.class.php - - - - message: '#^Property AccountancyCategory\:\:\$fk_country \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/accountancy/class/accountancycategory.class.php - - - - message: '#^Property AccountancyCategory\:\:\$formula \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/accountancy/class/accountancycategory.class.php - - - - message: '#^Property AccountancyCategory\:\:\$label \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/accountancy/class/accountancycategory.class.php - - - - message: '#^Property AccountancyCategory\:\:\$position \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/accountancy/class/accountancycategory.class.php - - - - message: '#^Property AccountancyCategory\:\:\$range_account \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/accountancy/class/accountancycategory.class.php - - - - message: '#^Property AccountancyCategory\:\:\$sens \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/accountancy/class/accountancycategory.class.php - - message: '#^Call to function is_array\(\) with list\ will always evaluate to true\.$#' identifier: function.alreadyNarrowedType diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 0b8dd671e2c..cb26c9e1a50 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2016-2017 Alexandre Spangaro - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2024-2025 MDW * * This program is free software; you can redistribute it and/or modify @@ -69,47 +69,47 @@ class AccountancyCategory // extends CommonObject public $id; /** - * @var string Accountancy code + * @var ?string Accountancy code */ public $code; /** - * @var string Accountancy Category label + * @var ?string Accountancy Category label */ public $label; /** - * @var string Accountancy range account + * @var ?string Accountancy range account */ public $range_account; /** - * @var int Sens of the account: 0: credit - debit, 1: debit - credit + * @var ?int Sens of the account: 0: credit - debit, 1: debit - credit */ public $sens; /** - * @var int Category type of accountancy + * @var ?int Category type of accountancy */ public $category_type; /** - * @var string Formula + * @var ?string Formula */ public $formula; /** - * @var int Position + * @var ?int Position */ public $position; /** - * @var int country id + * @var ?int country id */ public $fk_country; /** - * @var int Is active + * @var ?int Is active */ public $active; From 496fef63a3ab2fb7d6742f30df364b005f8282bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Tue, 23 Sep 2025 21:43:39 +0200 Subject: [PATCH 4/5] contact deletion in api_orders class for internal and external (#35455) * contact deletion in api_orders class for internal and external * Update api_orders.class.php --------- Co-authored-by: Laurent Destailleur --- htdocs/commande/class/api_orders.class.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 91252f216b4..89496742c03 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -691,14 +691,15 @@ class Orders extends DolibarrApi throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $contacts = $this->commande->liste_contact(); + foreach (array('internal', 'external') as $source) { + $contacts = $this->commande->liste_contact(-1, $source); + foreach ($contacts as $contact) { + if ($contact['id'] == $contactid && $contact['code'] == $type) { + $result = $this->commande->delete_contact($contact['rowid']); - foreach ($contacts as $contact) { - if ($contact['id'] == $contactid && $contact['code'] == $type) { - $result = $this->commande->delete_contact($contact['rowid']); - - if (!$result) { - throw new RestException(500, 'Error when deleted the contact'); + if (!$result) { + throw new RestException(500, 'Error when deleting the contact '.$contact['rowid']); + } } } } From cd03e9fc36b182e59844c64377a372eb7b751364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Tue, 23 Sep 2025 21:44:47 +0200 Subject: [PATCH 5/5] Add check for invoice status before line deletion (#35456) * Add check for invoice status before line deletion * Change invoice status check from fk_statut to status --- htdocs/compta/facture/class/api_invoices.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 27611b83895..c4c4c2f1b82 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -697,6 +697,9 @@ class Invoices extends DolibarrApi if (!$result) { throw new RestException(404, 'Invoice not found'); } + if ($this->invoice->status != 0) { + throw new RestException(403, 'Invoice not in Draft Status : '.$this->invoice->getLibStatut(1)); + } $updateRes = $this->invoice->deleteLine($lineid, $id); if ($updateRes > 0) {