diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index a825625573e..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 @@ -3894,12 +3840,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 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; 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']); + } } } } 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) { 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();