From 2782f32c1f3f384b5db4e0c77ef7ff17486721dc Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 18 Jan 2024 12:16:05 +0100 Subject: [PATCH 01/40] Fixed PHPDoc --- htdocs/resource/class/dolresource.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 92097ca3e1f..2a1d37a10de 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -46,7 +46,7 @@ class Dolresource extends CommonObject /** - * @var int ID + * @var string ID */ public $fk_code_type_resource; From 0934e44a8874899eb861e22bdee98daa0488957c Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 18 Jan 2024 12:16:40 +0100 Subject: [PATCH 02/40] Adjusted GETPOST check --- htdocs/resource/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 3783f0de394..5e21239ea01 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -41,7 +41,7 @@ $cancel = GETPOST('cancel', 'alpha'); $ref = GETPOST('ref', 'alpha'); $description = GETPOST('description', 'restricthtml'); $confirm = GETPOST('confirm', 'aZ09'); -$fk_code_type_resource = GETPOST('fk_code_type_resource', 'alpha'); +$fk_code_type_resource = GETPOST('fk_code_type_resource', 'aZ09'); $country_id = GETPOST('country_id', 'int'); // Protection if external user From 097a2206749783c51639ce6128f0382b5ec44998 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 18 Jan 2024 12:40:37 +0100 Subject: [PATCH 03/40] Cleaned code --- htdocs/resource/class/dolresource.class.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 2a1d37a10de..1bc71065074 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -597,9 +597,6 @@ class Dolresource extends CommonObject $error = 0; // Clean parameters - if (isset($this->resource_id)) { - $this->resource_id = trim($this->resource_id); - } if (isset($this->resource_type)) { $this->resource_type = trim($this->resource_type); } @@ -618,7 +615,7 @@ class Dolresource extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."element_resources SET"; - $sql .= " resource_id=".(isset($this->resource_id) ? "'".$this->db->escape($this->resource_id)."'" : "null").","; + $sql .= " resource_id=".(isset($this->resource_id) ? $this->resource_id : "null").","; $sql .= " resource_type=".(isset($this->resource_type) ? "'".$this->db->escape($this->resource_type)."'" : "null").","; $sql .= " element_id=".(isset($this->element_id) ? $this->element_id : "null").","; $sql .= " element_type=".(isset($this->element_type) ? "'".$this->db->escape($this->element_type)."'" : "null").","; From 99b0531ca7277516aa4dfdc9446a730c627f9311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 18 Jan 2024 22:43:17 +0100 Subject: [PATCH 04/40] fix phpstan --- htdocs/core/lib/accounting.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index b8d700ffb93..7b8cc48305e 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -3,7 +3,7 @@ * Copyright (C) 2013-2021 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2019 Eric Seigne - * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021-2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,8 +31,8 @@ * * @author Michael - https://www.php.net/manual/fr/function.empty.php#90767 * @param mixed $var Value to test - * @param int|null $allow_false Setting this to true will make the function consider a boolean value of false as NOT empty. This parameter is false by default. - * @param int|null $allow_ws Setting this to true will make the function consider a string with nothing but white space as NOT empty. This parameter is false by default. + * @param boolean $allow_false Setting this to true will make the function consider a boolean value of false as NOT empty. This parameter is false by default. + * @param boolean $allow_ws Setting this to true will make the function consider a string with nothing but white space as NOT empty. This parameter is false by default. * @return boolean True of False */ function is_empty($var, $allow_false = false, $allow_ws = false) From 6875f78356321f7268c32aa192f7cab4bd0fff0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 18 Jan 2024 22:58:05 +0100 Subject: [PATCH 05/40] fix phpstan --- htdocs/stripe/class/stripe.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index c100bdba1ca..8865693b0f3 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -339,11 +339,11 @@ class Stripe extends CommonObject * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect * @param int $status Status (0=test, 1=live) * @param int $usethirdpartyemailforreceiptemail 1=use thirdparty email for receipt - * @param int $mode automatic=automatic confirmation/payment when conditions are ok, manual=need to call confirm() on intent + * @param string $mode automatic=automatic confirmation/payment when conditions are ok, manual=need to call confirm() on intent * @param boolean $confirmnow false=default, true=try to confirm immediately after create (if conditions are ok) * @param string $payment_method 'pm_....' (if known) - * @param string $off_session If we use an already known payment method to pay when customer is not available during the checkout flow. - * @param string $noidempotency_key Do not use the idempotency_key when creating the PaymentIntent + * @param int $off_session If we use an already known payment method to pay when customer is not available during the checkout flow. + * @param int $noidempotency_key Do not use the idempotency_key when creating the PaymentIntent * @param int $did ID of an existing line into llx_prelevement_demande (Dolibarr intent). If provided, no new line will be created. * @return \Stripe\PaymentIntent|null Stripe PaymentIntent or null if not found and failed to create */ From 5dc5e42a2918c48a6e3c930a6a651ce7c6727eef Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 18 Jan 2024 23:06:52 +0100 Subject: [PATCH 06/40] Fix: Add missing argument to dol_print_error # Fix: Add missing argument to dol_print_error Required argument was missing. --- htdocs/user/vcard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/vcard.php b/htdocs/user/vcard.php index 695cd0e556e..a59e4e62872 100644 --- a/htdocs/user/vcard.php +++ b/htdocs/user/vcard.php @@ -44,7 +44,7 @@ $result = restrictedArea($user, 'user', $id, 'user', $feature2); $object = new User($db); $result = $object->fetch($id); if ($result <= 0) { - dol_print_error($object->error); + dol_print_error($db, $object->error); exit; } From 68d771c0d9ae3aee8eadd3c564d639ed16b9d56f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 18 Jan 2024 23:07:18 +0100 Subject: [PATCH 07/40] clean code --- htdocs/stripe/config.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/stripe/config.php b/htdocs/stripe/config.php index 7b202daaf47..a50dbf71a86 100644 --- a/htdocs/stripe/config.php +++ b/htdocs/stripe/config.php @@ -33,13 +33,13 @@ global $conf; global $stripearrayofkeysbyenv; $stripearrayofkeysbyenv = array( - 0=>array( - "secret_key" => !getDolGlobalString('STRIPE_TEST_SECRET_KEY') ? '' : $conf->global->STRIPE_TEST_SECRET_KEY, - "publishable_key" => !getDolGlobalString('STRIPE_TEST_PUBLISHABLE_KEY') ? '' : $conf->global->STRIPE_TEST_PUBLISHABLE_KEY + array( + "secret_key" => getDolGlobalString('STRIPE_TEST_SECRET_KEY'), + "publishable_key" => getDolGlobalString('STRIPE_TEST_PUBLISHABLE_KEY') ), - 1=>array( - "secret_key" => !getDolGlobalString('STRIPE_LIVE_SECRET_KEY') ? '' : $conf->global->STRIPE_LIVE_SECRET_KEY, - "publishable_key" => !getDolGlobalString('STRIPE_LIVE_PUBLISHABLE_KEY') ? '' : $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY + array( + "secret_key" => getDolGlobalString('STRIPE_LIVE_SECRET_KEY'), + "publishable_key" => getDolGlobalString('STRIPE_LIVE_PUBLISHABLE_KEY') ) ); From eb8960bcd12f390fdfd1f0775ab098ccb5cfc264 Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 18 Jan 2024 23:04:20 +0100 Subject: [PATCH 08/40] Qual: Cleanup method to ignore misspelled key # Qual: Cleanup method to ignore misspelled key With the method to ignore lines, the code can be cleaned up to ignore the spelling issue. --- dev/tools/codespell/codespell-lines-ignore.txt | 3 ++- htdocs/core/lib/admin.lib.php | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dev/tools/codespell/codespell-lines-ignore.txt b/dev/tools/codespell/codespell-lines-ignore.txt index 2f1cfff2ccc..0d4e979d84a 100644 --- a/dev/tools/codespell/codespell-lines-ignore.txt +++ b/dev/tools/codespell/codespell-lines-ignore.txt @@ -1,4 +1,5 @@ - + $objMod->dictionaries = $objMod->{"dictionnaries"}; // For backward compatibility + if (empty($objMod->dictionaries) && !empty($objMod->{"dictionnaries"})) { print 'id.'">'; $reponsesadd = str_split($obj->reponses); $sql .= " SET reponses = '".$db->escape($reponsesadd)."'"; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 3afbc7bd247..c0d7baad366 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1379,9 +1379,8 @@ function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tab // phpcs:disable // Complete the arrays &$tabname,&$tablib,&$tabsql,&$tabsqlsort,&$tabfield,&$tabfieldvalue,&$tabfieldinsert,&$tabrowid,&$tabcond - // Note: "diction"."naries" to prevent codespell from detecting a spelling error. - if (empty($objMod->dictionaries) && !empty($objMod->{"dicton"."naries"})) { - $objMod->dictionaries = $objMod->{"diction"."naries"}; // For backward compatibility + if (empty($objMod->dictionaries) && !empty($objMod->{"dictionnaries"})) { + $objMod->dictionaries = $objMod->{"dictionnaries"}; // For backward compatibility } // phpcs:enable From 4b3f351f95d1471a75ec14672c72b9be7ae8bd1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Thu, 18 Jan 2024 23:28:42 +0100 Subject: [PATCH 09/40] phpdoc --- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/facture/class/facture-rec.class.php | 3 +++ htdocs/core/class/commoninvoice.class.php | 3 +++ htdocs/fourn/class/fournisseur.commande.class.php | 3 +++ htdocs/fourn/class/fournisseur.facture-rec.class.php | 3 +++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index e0b71e06fa5..13b0f27c4ae 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -131,7 +131,7 @@ class Commande extends CommonOrder public $billed; /** - * @var string Limit date payment + * @var int Deadline for payment */ public $date_lim_reglement; /** diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 311a1d1ce81..9f4d944fb29 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -132,6 +132,9 @@ class FactureRec extends CommonInvoice public $usenewprice = 0; + /** + * @var int Deadline for payment + */ public $date_lim_reglement; public $cond_reglement_code; // Code in llx_c_paiement public $mode_reglement_code; // Code in llx_c_paiement diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index eb7f83387b1..e52020234b4 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -69,6 +69,9 @@ abstract class CommonInvoice extends CommonObject */ public $date; + /** + * @var int Deadline for payment + */ public $date_lim_reglement; public $cond_reglement_id; // Id in llx_c_paiement diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index c27f02c842b..e5fabd8d3eb 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -212,6 +212,9 @@ class CommandeFournisseur extends CommonOrder public $origin_id; public $linked_objects = array(); + /** + * @var int Deadline for payment + */ public $date_lim_reglement; public $receptions = array(); diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 1d47ada460f..26fffd8a8fc 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -125,6 +125,9 @@ class FactureFournisseurRec extends CommonInvoice public $cond_reglement_doc; public $cond_reglement_id; + /** + * @var int Deadline for payment + */ public $date_lim_reglement; public $usenewprice = 0; From 707c1d18bc9fb9e1743a81d9310659ecc3d1a022 Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 18 Jan 2024 23:53:34 +0100 Subject: [PATCH 10/40] Fix: Missing 'ref_supplier' argument # Fix: Missing 'ref_supplier' argument Argument ref_supplier was missing. According to code read for the class, ->ref_fourn is ok, but please double check --- htdocs/supplier_proposal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 09e5cdc0de8..4f822fa60db 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -574,7 +574,7 @@ if (empty($reshook)) { $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc); foreach ($object->lines as $line) { - $result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); + $result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->ref_fourn, $line->fk_unit, $line->multicurrency_subprice); } } elseif ($action == 'addline' && $usercancreate) { $langs->load('errors'); From c98868d2db0c02a3283b295b3d7cf20ffa35fb4d Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 19 Jan 2024 01:33:45 +0100 Subject: [PATCH 11/40] Fix: Update Stripe Exception class references # Fix: Update Stripe Exception class references The Stripe classes changed, update the references. --- htdocs/public/payment/newpayment.php | 14 +++++++------- htdocs/stripe/class/stripe.class.php | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index dbbe83affc2..7f0490629b0 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -662,8 +662,8 @@ if ($action == 'charge' && isModEnabled('stripe')) { $action = ''; } } - } catch (\Stripe\Error\Card $e) { - // Since it's a decline, \Stripe\Error\Card will be caught + } catch (\Stripe\Exception\CardException $e) { + // Since it's a decline, \Stripe\Exception\Card will be caught $body = $e->getJsonBody(); $err = $body['error']; @@ -679,21 +679,21 @@ if ($action == 'charge' && isModEnabled('stripe')) { dol_syslog($errormessage, LOG_WARNING, 0, '_payment'); setEventMessages($e->getMessage(), null, 'errors'); $action = ''; - } catch (\Stripe\Error\RateLimit $e) { + } catch (\Stripe\Exception\RateLimitException $e) { // Too many requests made to the API too quickly $error++; $errormessage = "ErrorRateLimit ".$e->getMessage(); dol_syslog($errormessage, LOG_WARNING, 0, '_payment'); setEventMessages($e->getMessage(), null, 'errors'); $action = ''; - } catch (\Stripe\Error\InvalidRequest $e) { + } catch (\Stripe\Exception\InvalidRequestException $e) { // Invalid parameters were supplied to Stripe's API $error++; $errormessage = "ErrorInvalidRequest ".$e->getMessage(); dol_syslog($errormessage, LOG_WARNING, 0, '_payment'); setEventMessages($e->getMessage(), null, 'errors'); $action = ''; - } catch (\Stripe\Error\Authentication $e) { + } catch (\Stripe\Exception\AuthenticationException $e) { // Authentication with Stripe's API failed // (maybe you changed API keys recently) $error++; @@ -701,14 +701,14 @@ if ($action == 'charge' && isModEnabled('stripe')) { dol_syslog($errormessage, LOG_WARNING, 0, '_payment'); setEventMessages($e->getMessage(), null, 'errors'); $action = ''; - } catch (\Stripe\Error\ApiConnection $e) { + } catch (\Stripe\Exception\ApiConnectionException $e) { // Network communication with Stripe failed $error++; $errormessage = "ErrorApiConnection ".$e->getMessage(); dol_syslog($errormessage, LOG_WARNING, 0, '_payment'); setEventMessages($e->getMessage(), null, 'errors'); $action = ''; - } catch (\Stripe\Error\Base $e) { + } catch (\Stripe\Exception\ExceptionInterface $e) { // Display a very generic error to the user, and maybe send // yourself an email $error++; diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index c100bdba1ca..6e3715b7f75 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -603,7 +603,7 @@ class Stripe extends CommonObject } else { $_SESSION["stripe_payment_intent"] = $paymentintent; } - } catch (Stripe\Error\Card $e) { + } catch (Stripe\Exception\CardException $e) { $error++; $this->error = $e->getMessage(); $this->code = $e->getStripeCode(); @@ -1354,9 +1354,9 @@ class Stripe extends CommonObject $return->message = $charge->id; } } - } catch (\Stripe\Error\Card $e) { + } catch (\Stripe\Exception\CardException $e) { include DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - // Since it's a decline, \Stripe\Error\Card will be caught + // Since it's a decline, \Stripe\Exception\Card will be caught $body = $e->getJsonBody(); $err = $body['error']; @@ -1372,24 +1372,24 @@ class Stripe extends CommonObject $error++; dol_syslog($e->getMessage(), LOG_WARNING, 0, '_stripe'); - } catch (\Stripe\Error\RateLimit $e) { + } catch (\Stripe\Exception\RateLimitException $e) { // Too many requests made to the API too quickly $error++; dol_syslog($e->getMessage(), LOG_WARNING, 0, '_stripe'); - } catch (\Stripe\Error\InvalidRequest $e) { + } catch (\Stripe\Exception\InvalidRequestException $e) { // Invalid parameters were supplied to Stripe's API $error++; dol_syslog($e->getMessage(), LOG_WARNING, 0, '_stripe'); - } catch (\Stripe\Error\Authentication $e) { + } catch (\Stripe\Exception\AuthenticationException $e) { // Authentication with Stripe's API failed // (maybe you changed API keys recently) $error++; dol_syslog($e->getMessage(), LOG_WARNING, 0, '_stripe'); - } catch (\Stripe\Error\ApiConnection $e) { + } catch (\Stripe\Exception\ApiConnectionException $e) { // Network communication with Stripe failed $error++; dol_syslog($e->getMessage(), LOG_WARNING, 0, '_stripe'); - } catch (\Stripe\Error\Base $e) { + } catch (\Stripe\Exception\ExceptionInterface $e) { // Display a very generic error to the user, and maybe send // yourself an email $error++; From 00d1b26d0689dbc62355a622d584299b08cd6793 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 08:46:08 +0100 Subject: [PATCH 12/40] qual: phpstan htdocs/admin/defaultvalues.php 163 Property CommonObject::$id (int) does not accept array|string. htdocs/admin/defaultvalues.php 186 Property CommonObject::$id (int) does not accept array|string. --- htdocs/admin/defaultvalues.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index bf7eb7d27bf..5c92e5acd14 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -40,7 +40,7 @@ if (!$user->admin) { accessforbidden(); } -$id = GETPOST('rowid', 'int'); +$id = GETPOSTINT('rowid'); $action = GETPOST('action', 'aZ09'); $optioncss = GETPOST('optionscss', 'alphanohtml'); From ba499631861fa1b29af707fb82277660cb342e7e Mon Sep 17 00:00:00 2001 From: Christophe TREMBLAY-GUILLOUX Date: Fri, 19 Jan 2024 08:55:39 +0100 Subject: [PATCH 13/40] CLEANING: lines of code not usefull --- htdocs/cron/class/cronjob.class.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 7e55e65f8f8..833d0068e14 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -587,12 +587,6 @@ class Cronjob extends CommonObject $sql .= $this->db->plimit($limit + 1, $offset); } - $sqlwhere = array(); - - if (count($sqlwhere) > 0) { - $sql .= " WHERE ".implode(' AND ', $sqlwhere); - } - dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { From c477a723e4b140e27d37740b14ed23674362ca86 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 19 Jan 2024 09:00:53 +0100 Subject: [PATCH 14/40] feat: knowledgemanagement change answer column to longtext --- htdocs/install/mysql/migration/19.0.0-20.0.0.sql | 4 +++- ...nowledgemanagement_knowledgerecord-knowledgemanagement.sql | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index 28e61371e66..6a3f61a22d2 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -205,4 +205,6 @@ ALTER TABLE llx_c_tva ADD COLUMN type_vat smallint NOT NULL DEFAULT 0 AFTER fk_p ALTER TABLE llx_categorie ADD COLUMN position integer DEFAULT 0 AFTER color; -ALTER TABLE llx_product DROP COLUMN onportal; +ALTER TABLE llx_product DROP COLUMN onportal; + +ALTER TABLE llx_knowledgemanagement_knowledgerecord MODIFY COLUMN answer longtext; diff --git a/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord-knowledgemanagement.sql b/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord-knowledgemanagement.sql index a12c73b9cde..f3aca05c1e8 100644 --- a/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord-knowledgemanagement.sql +++ b/htdocs/install/mysql/tables/llx_knowledgemanagement_knowledgerecord-knowledgemanagement.sql @@ -29,7 +29,7 @@ CREATE TABLE llx_knowledgemanagement_knowledgerecord( import_key varchar(14), model_pdf varchar(255), question text NOT NULL, - answer text, + answer longtext, url varchar(255), fk_ticket integer, fk_c_ticket_category integer, From ee101fd6ff604dfc0ba79ec65501c47666051953 Mon Sep 17 00:00:00 2001 From: William Mead Date: Fri, 19 Jan 2024 10:45:55 +0100 Subject: [PATCH 15/40] Updated code comments --- htdocs/resource/class/dolresource.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index a747c66a038..702916b3ba9 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2023 William Mead +/* Copyright (C) 2013-2015 Jean-François Ferry + * Copyright (C) 2023-2024 William Mead * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -104,7 +104,7 @@ class Dolresource extends CommonObject public $tms; /** - * Used by fetch_element_resource() to return an object + * Used by fetchElementResource() to return an object */ public $objelement; From 552485ea81b23356c0d115492c374e6d127a9560 Mon Sep 17 00:00:00 2001 From: William Mead Date: Fri, 19 Jan 2024 11:17:40 +0100 Subject: [PATCH 16/40] Updated GETPOST to GETPOSTINT. Updated contributor details. --- htdocs/resource/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 2c4876e88ce..1fd68eeec63 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2023 William Mead + * Copyright (C) 2023-2024 William Mead * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->loadLangs(array('resource', 'companies', 'other', 'main')); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOSTINT('id'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $ref = GETPOST('ref', 'alpha'); @@ -46,8 +46,8 @@ $town = GETPOST('town', 'alpha'); $description = GETPOST('description', 'restricthtml'); $confirm = GETPOST('confirm', 'aZ09'); $fk_code_type_resource = GETPOST('fk_code_type_resource', 'aZ09'); -$country_id = GETPOST('country_id', 'int'); -$state_id = GETPOSTINT('state_id', 'int'); +$country_id = GETPOSTINT('country_id'); +$state_id = GETPOSTINT('state_id'); // Protection if external user if ($user->socid > 0) { From 89257dbd76d6571ea24600dc55061f5725cc313e Mon Sep 17 00:00:00 2001 From: William Mead Date: Fri, 19 Jan 2024 11:32:19 +0100 Subject: [PATCH 17/40] Updated parameter clean for numeric values --- htdocs/resource/class/dolresource.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 702916b3ba9..bdb0a126f18 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -634,11 +634,14 @@ class Dolresource extends CommonObject $error = 0; // Clean parameters + if (!is_numeric($this->resource_id)) { + $this->resource_id = 0; + } if (isset($this->resource_type)) { $this->resource_type = trim($this->resource_type); } - if (isset($this->element_id)) { - $this->element_id = trim($this->element_id); + if (!is_numeric($this->element_id)) { + $this->element_id = 0; } if (isset($this->element_type)) { $this->element_type = trim($this->element_type); From 9039db9f54731b91b316286de8bf00ee1829eebb Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 12:40:40 +0100 Subject: [PATCH 18/40] qual: phpstan htdocs/admin/expensereport_rules.php 128 Property ExpenseReportRule::$restrictive (int) does not accept array|string. htdocs/admin/expensereport_rules.php 129 Property ExpenseReportRule::$fk_c_type_fees (int) does not accept array|string. htdocs/admin/expensereport_rules.php 131 Property ExpenseReportRule::$amount (float) does not accept string. --- htdocs/admin/expensereport_rules.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 968fdea81af..e8415d5704e 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -65,12 +65,12 @@ if (empty($reshook)) { $apply_to = GETPOST('apply_to'); $fk_user = GETPOST('fk_user', 'int'); $fk_usergroup = GETPOST('fk_usergroup', 'int'); - $restrictive = GETPOST('restrictive', 'int'); - $fk_c_type_fees = GETPOST('fk_c_type_fees', 'int'); + $restrictive = GETPOSTINT('restrictive'); + $fk_c_type_fees = GETPOSTINT('fk_c_type_fees'); $code_expense_rules_type = GETPOST('code_expense_rules_type'); $dates = dol_mktime(12, 0, 0, GETPOST('startmonth'), GETPOST('startday'), GETPOST('startyear')); $datee = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - $amount = price2num(GETPOST('amount'), 'MT', 2); + $amount = (float) price2num(GETPOST('amount'), 'MT', 2); if (!empty($id)) { $result = $object->fetch($id); From afe1064b24d0b8c330e6ed0ab4524bbb09873d12 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 12:43:06 +0100 Subject: [PATCH 19/40] qual: phpstan htdocs/bookmarks/card.php 89 Property Bookmark::$fk_user (int) does not accept array|string. htdocs/bookmarks/card.php 94 Property Bookmark::$position (int) does not accept array|string. --- htdocs/bookmarks/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index 7bebdcb2af7..d9d887ab4d4 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -40,8 +40,8 @@ $title = (string) GETPOST("title", "alpha"); $url = (string) GETPOST("url", "alpha"); $urlsource = GETPOST("urlsource", "alpha"); $target = GETPOST("target", "int"); -$userid = GETPOST("userid", "int"); -$position = GETPOST("position", "int"); +$userid = GETPOSTINT("userid"); +$position = GETPOSTINT("position"); $backtopage = GETPOST('backtopage', 'alpha'); From 5f4d1a55c351e7398ab4e5d1a45872493a5e4dd3 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 12:46:44 +0100 Subject: [PATCH 20/40] qual: phpstan htdocs/comm/action/card.php 371 Property ActionComm::$fk_element (int) does not accept array|string. htdocs/comm/action/card.php 397 Property ActionComm::$fk_element (int) does not accept array|string. htdocs/comm/action/card.php 429 Property ActionComm::$userdoneid (int) does not accept array|string. htdocs/comm/action/card.php 440 Property ActionComm::$socid (int) does not accept array|string. htdocs/comm/action/card.php 549 Property ActionCommReminder::$fk_email_template (int) does not accept array|string. htdocs/comm/action/card.php 666 Property ActionCommReminder::$fk_email_template (int) does not accept array|string. htdocs/comm/action/card.php 998 Property ActionCommReminder::$fk_email_template (int) does not accept array|string. --- htdocs/comm/action/card.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index eefec70803d..9890bf275d4 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -72,7 +72,7 @@ $addreminder = GETPOST('addreminder', 'alpha'); $offsetvalue = GETPOSTINT('offsetvalue'); $offsetunit = GETPOST('offsetunittype_duration', 'aZ09'); $remindertype = GETPOST('selectremindertype', 'aZ09'); -$modelmail = GETPOST('actioncommsendmodel_mail', 'int'); +$modelmail = GETPOSTINT('actioncommsendmodel_mail'); $complete = GETPOST('complete', 'alpha'); // 'na' must be allowed $private = GETPOST('private', 'alphanohtml'); if ($complete == 'na' || $complete == -2) { @@ -368,7 +368,7 @@ if (empty($reshook) && $action == 'add') { $hasPermissionOnLinkedObject = 1; } if ($hasPermissionOnLinkedObject) { - $object->fk_element = GETPOST("fk_element", 'int'); + $object->fk_element = GETPOSTINT("fk_element"); $object->elementtype = GETPOST("elementtype", 'alpha'); } } @@ -387,7 +387,7 @@ if (empty($reshook) && $action == 'add') { } $object->fk_project = GETPOSTISSET("projectid") ? GETPOST("projectid", 'int') : 0; - $taskid = GETPOST('taskid', 'int'); + $taskid = GETPOSTINT('taskid'); if (!empty($taskid)) { $taskProject = new Task($db); if ($taskProject->fetch($taskid) > 0) { @@ -426,7 +426,7 @@ if (empty($reshook) && $action == 'add') { if (!$error && getDolGlobalString('AGENDA_ENABLE_DONEBY')) { if (GETPOST("doneby") > 0) { - $object->userdoneid = GETPOST("doneby", "int"); + $object->userdoneid = GETPOSTINT("doneby"); } } @@ -437,7 +437,7 @@ if (empty($reshook) && $action == 'add') { } if (GETPOST('socid', 'int') > 0) { - $object->socid = GETPOST('socid', 'int'); + $object->socid = GETPOSTINT('socid'); $object->fetch_thirdparty(); $object->societe = $object->thirdparty; // For backward compatibility From a85cdcb8712f89dabe9a1deef4846926b9dd8301 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 12:48:36 +0100 Subject: [PATCH 21/40] qual: phpstan htdocs/comm/card.php 221 Property Societe::$tva_assuj (int) does not accept array|string. htdocs/comm/card.php 231 Property Societe::$fk_prospectlevel (int) does not accept array|string. --- htdocs/comm/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 230f9b4a43d..102362b3adb 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -218,7 +218,7 @@ if (empty($reshook)) { // assujetissement a la TVA if ($action == 'setassujtva' && $user->hasRight('societe', 'creer')) { $object->fetch($id); - $object->tva_assuj = GETPOST('assujtva_value'); + $object->tva_assuj = GETPOSTINT('assujtva_value'); $result = $object->update($object->id); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -228,7 +228,7 @@ if (empty($reshook)) { // set prospect level if ($action == 'setprospectlevel' && $user->hasRight('societe', 'creer')) { $object->fetch($id); - $object->fk_prospectlevel = GETPOST('prospect_level_id', 'alpha'); + $object->fk_prospectlevel = GETPOSTINT('prospect_level_id'); $result = $object->update($object->id, $user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); From d08b29bc12729d07b04c7f871525e5f4e8bf1243 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 13:05:58 +0100 Subject: [PATCH 22/40] qual: phpstan htdocs/compta/facture/card.php 531 Property Facture::$revenuestamp (float) does not accept array|string. htdocs/compta/facture/card.php 1006 Property CommonInvoice::$socid (int) does not accept array|string. htdocs/compta/facture/card.php 1705 Property DiscountAbsolute::$fk_soc (int) does not accept array|string. --- htdocs/compta/facture/card.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 821b7cb6e62..864aa03695e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -528,7 +528,7 @@ if (empty($reshook)) { } } elseif ($action == 'setrevenuestamp' && $usercancreate) { $object->fetch($id); - $object->revenuestamp = GETPOST('revenuestamp'); + $object->revenuestamp = (float) GETPOST('revenuestamp','int'); $result = $object->update($user); $object->update_price(1); if ($result < 0) { @@ -1003,7 +1003,7 @@ if (empty($reshook)) { } elseif ($action == 'add' && $usercancreate) { // Insert new invoice in database if ($socid > 0) { - $object->socid = GETPOST('socid', 'int'); + $object->socid = GETPOSTINT('socid'); } if (GETPOST('type', 'int') === '') { @@ -1104,7 +1104,7 @@ if (empty($reshook)) { if (!empty($originentity)) { $object->entity = $originentity; } - $object->socid = GETPOST('socid', 'int'); + $object->socid = GETPOSTINT('socid'); $object->subtype = GETPOST('subtype'); $object->ref = GETPOST('ref'); $object->date = $dateinvoice; @@ -1326,7 +1326,7 @@ if (empty($reshook)) { } if (!$error) { - $object->socid = GETPOST('socid', 'int'); + $object->socid = GETPOSTINT('socid'); $object->type = GETPOST('type'); $object->subtype = GETPOST('subtype'); $object->ref = GETPOST('ref'); @@ -1413,7 +1413,7 @@ if (empty($reshook)) { } if (!$error) { - $object->socid = GETPOST('socid', 'int'); + $object->socid = GETPOSTINT('socid'); $object->type = GETPOST('type'); $object->subtype = GETPOST('subtype'); $object->ref = GETPOST('ref'); From 7073567fc7a25a90876a3741b0e4991eb86c5daf Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 13:09:10 +0100 Subject: [PATCH 23/40] typo --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 864aa03695e..1b2d52f25de 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -528,7 +528,7 @@ if (empty($reshook)) { } } elseif ($action == 'setrevenuestamp' && $usercancreate) { $object->fetch($id); - $object->revenuestamp = (float) GETPOST('revenuestamp','int'); + $object->revenuestamp = (float) GETPOST('revenuestamp', 'int'); $result = $object->update($user); $object->update_price(1); if ($result < 0) { From 571e46f5bedbc34f391f19b2d9758a84b5827681 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 19 Jan 2024 15:45:54 +0100 Subject: [PATCH 24/40] fix selectgroupticket to prevent some bugs --- htdocs/core/class/html.formticket.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 13af895a1b0..4a91f083f41 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -941,7 +941,7 @@ class FormTicket $stringtoprint .= ''; $sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, "; - $sql .= $this->db->ifsql("ctc.rowid NOT IN (SELECT ctcfather.rowid FROM llx_c_ticket_category as ctcfather JOIN llx_c_ticket_category as ctcjoin ON ctcfather.rowid = ctcjoin.fk_parent)", "'NOTPARENT'", "'PARENT'")." as isparent"; + $sql .= $this->db->ifsql("ctc.rowid NOT IN (SELECT ctcfather.rowid FROM llx_c_ticket_category as ctcfather JOIN llx_c_ticket_category as ctcjoin ON ctcfather.rowid = ctcjoin.fk_parent WHERE ctcjoin.active > 0)", "'NOTPARENT'", "'PARENT'")." as isparent"; $sql .= " FROM ".$this->db->prefix()."c_ticket_category as ctc"; $sql .= " WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity); if ($filtertype == 'public=1') { @@ -989,8 +989,8 @@ class FormTicket if (count($arrayidused) == 1) { return ''; } else { - $stringtoprint .= ''; - $stringtoprint .= ''; + $stringtoprint .= ''; + $stringtoprint .= ''; } $stringtoprint .= ' '; @@ -1134,6 +1134,10 @@ class FormTicket $stringtoprint .='$("#'.$htmlname.'_child_'.$use_multilevel.'").change(function() { $("#ticketcategory_select").val($(this).val()); $("#ticketcategory_select_child_id").val($(this).attr("child_id")); + tmpvalselect = $("#ticketcategory_select").val(); + if(tmpvalselect == "" && $("#ticketcategory_select_child_id").val() >= 1){ + $("#ticketcategory_select_child_id").val($(this).attr("child_id")-1); + } console.log($("#ticketcategory_select").val()); })'; $stringtoprint .=''; From 2247b39b18b1af8401a1cc822ddd2138fbfd9711 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 17:35:00 +0100 Subject: [PATCH 25/40] fk_prospectlevel is a "false friend". It real type is string. --- htdocs/comm/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 102362b3adb..ded202f899f 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -228,7 +228,7 @@ if (empty($reshook)) { // set prospect level if ($action == 'setprospectlevel' && $user->hasRight('societe', 'creer')) { $object->fetch($id); - $object->fk_prospectlevel = GETPOSTINT('prospect_level_id'); + $object->fk_prospectlevel = GETPOST('prospect_level_id', 'alpha'); $result = $object->update($object->id, $user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); From 88090f0275d9e7cc1a90a46df81c51a64972138c Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 17:46:17 +0100 Subject: [PATCH 26/40] apply price2num() on GETPOST('revenuestamp') --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 1b2d52f25de..04e580f7681 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -528,7 +528,7 @@ if (empty($reshook)) { } } elseif ($action == 'setrevenuestamp' && $usercancreate) { $object->fetch($id); - $object->revenuestamp = (float) GETPOST('revenuestamp', 'int'); + $object->revenuestamp = (float) price2num(GETPOST('revenuestamp')); $result = $object->update($user); $object->update_price(1); if ($result < 0) { From f981a64720a34975788d4441e4229a44aa9d160b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 19 Jan 2024 18:11:30 +0100 Subject: [PATCH 27/40] fix phpdoc and default value --- htdocs/core/lib/functions.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index add7175614b..00adc0bffae 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5346,13 +5346,13 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss * This function must be called when a blocking technical error is encountered. * However, one must try to call it only within php pages, classes must return their error through their property "error". * - * @param DoliDB|string $db Database handler + * @param DoliDB|null $db Database handler * @param string|string[] $error String or array of errors strings to show - * @param array $errors Array of errors + * @param string[]|null $errors Array of errors * @return void * @see dol_htmloutput_errors() */ -function dol_print_error($db = '', $error = '', $errors = null) +function dol_print_error($db = null, $error = '', $errors = null) { global $conf, $langs, $argv; global $dolibarr_main_prod; From 376733e070228ff7651cd8e4d4373cc2000da95c Mon Sep 17 00:00:00 2001 From: Roger Dueck Date: Fri, 19 Jan 2024 10:16:33 -0700 Subject: [PATCH 28/40] Fix PHP undefined variable warning --- htdocs/cron/class/cronjob.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 7e55e65f8f8..7cd19299520 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1330,7 +1330,7 @@ class Cronjob extends CommonObject $error++; } else { dol_syslog(get_class($this)."::run_jobs END"); - $this->lastoutput = dol_substr((empty($object->output) ? "" : $object->output."\n").$errmsg, 0, $this::MAXIMUM_LENGTH_FOR_LASTOUTPUT_FIELD, 'UTF-8', 1); + $this->lastoutput = dol_substr((empty($object->output) ? "" : $object->output."\n"), 0, $this::MAXIMUM_LENGTH_FOR_LASTOUTPUT_FIELD, 'UTF-8', 1); $this->lastresult = var_export($result, true); $retval = $this->lastresult; } From 0dc9c2c6b5300d51041db36e3c88cb4f170153c3 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 20:01:26 +0100 Subject: [PATCH 29/40] qual: phpstan htdocs/loan/payment/payment.php 155 Property PaymentLoan::$fk_bank (int) does not accept array|string. htdocs/loan/payment/payment.php 157 Property PaymentLoan::$num_payment (int) does not accept array|string. htdocs/loan/payment/payment.php 185 Property LoanSchedule::$fk_bank (int) does not accept array|string. --- htdocs/loan/payment/payment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index fd66843f7b5..1cfdc7aa477 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -152,9 +152,9 @@ if ($action == 'add_payment') { $payment->amount_capital = $pay_amount_capital; $payment->amount_insurance = $pay_amount_insurance; $payment->amount_interest = $pay_amount_interest; - $payment->fk_bank = GETPOST('accountid', 'int'); + $payment->fk_bank = GETPOSTINT('accountid'); $payment->paymenttype = GETPOST('paymenttype', 'int'); - $payment->num_payment = GETPOST('num_payment'); + $payment->num_payment = GETPOSTINT('num_payment'); $payment->note_private = GETPOST('note_private', 'restricthtml'); $payment->note_public = GETPOST('note_public', 'restricthtml'); From f5d064175f87b9736a1ee4735768ce8e9597c6e1 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 20:06:03 +0100 Subject: [PATCH 30/40] qual: phsptan htdocs/projet/stats/index.php 86 Property Stats::$year (int) does not accept array|string. htdocs/projet/stats/index.php 204 Property Stats::$year (int) does not accept array|string. --- htdocs/projet/stats/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php index eeb33ccf2ed..25af61c3a7f 100644 --- a/htdocs/projet/stats/index.php +++ b/htdocs/projet/stats/index.php @@ -42,7 +42,7 @@ if ($user->socid > 0) { $socid = $user->socid; } $nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); -$year = GETPOST('year', 'int') > 0 ? GETPOST('year', 'int') : $nowyear; +$year = GETPOSTINT('year') > 0 ? GETPOSTINT('year') : $nowyear; $startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); $endyear = $year; From 26b845e052d492233e20c09cf63f049e0ecda5af Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 20:09:21 +0100 Subject: [PATCH 31/40] qual: phpstan htdocs/public/partnership/new.php 275 Property Societe::$country_id (int) does not accept array|string. htdocs/public/partnership/new.php 276 Property CommonObject::$state_id (int) does not accept array|string. htdocs/public/partnership/new.php 303 Property Societe::$country_id (int) does not accept array|string. htdocs/public/partnership/new.php 312 Property CommonObject::$state_id (int) does not accept array|string. --- htdocs/public/partnership/new.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index 5fb9e2b194b..a3e6f0ffbc1 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -272,8 +272,8 @@ if (empty($reshook) && $action == 'add') { $company->town = GETPOST('town'); $company->email = GETPOST('email'); $company->url = GETPOST('url'); - $company->country_id = GETPOST('country_id', 'int'); - $company->state_id = GETPOST('state_id', 'int'); + $company->country_id = GETPOSTINT('country_id'); + $company->state_id = GETPOSTINT('state_id'); $company->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname')); $resultat=$company->create($user); @@ -300,7 +300,7 @@ if (empty($reshook) && $action == 'add') { $company->town = GETPOST('town'); } if (empty($company->country_id)) { - $company->country_id = GETPOST('country_id', 'int'); + $company->country_id = GETPOSTINT('country_id'); } if (empty($company->email)) { $company->email = GETPOST('email'); @@ -309,7 +309,7 @@ if (empty($reshook) && $action == 'add') { $company->url = GETPOST('url'); } if (empty($company->state_id)) { - $company->state_id = GETPOST('state_id', 'int'); + $company->state_id = GETPOSTINT('state_id'); } if (empty($company->name_alias)) { $company->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname')); From 6a36b8f0b8494ce2eae6fd20f4071fc8ebde2782 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 20:12:17 +0100 Subject: [PATCH 32/40] qual: phpstan htdocs/public/project/new.php 231 Property Societe::$country_id (int) does not accept array|string. htdocs/public/project/new.php 232 Property CommonObject::$state_id (int) does not accept array|string. --- htdocs/public/project/new.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index b3f553ba5b1..2674f6dddaa 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -228,8 +228,8 @@ if (empty($reshook) && $action == 'add') { $thirdparty->address = GETPOST('address'); $thirdparty->zip = GETPOST('zip'); $thirdparty->town = GETPOST('town'); - $thirdparty->country_id = GETPOST('country_id', 'int'); - $thirdparty->state_id = GETPOST('state_id'); + $thirdparty->country_id = GETPOSTINT('country_id'); + $thirdparty->state_id = GETPOSTINT('state_id'); $thirdparty->client = $thirdparty::PROSPECT; $thirdparty->code_client = 'auto'; $thirdparty->code_fournisseur = 'auto'; From 1ca92fe72e98e3e1bf99a9429f8b309c74238a3a Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 20:14:10 +0100 Subject: [PATCH 33/40] qual: phpstan htdocs/public/project/suggestbooth.php 258 Property Societe::$country_id (int) does not accept array|string. htdocs/public/project/suggestbooth.php 259 Property CommonObject::$state_id (int) does not accept array|string. --- htdocs/public/project/suggestbooth.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/project/suggestbooth.php b/htdocs/public/project/suggestbooth.php index d6d59113ab5..49ec4f9cd17 100644 --- a/htdocs/public/project/suggestbooth.php +++ b/htdocs/public/project/suggestbooth.php @@ -255,8 +255,8 @@ if (empty($reshook) && $action == 'add') { $thirdparty->town = GETPOST("town"); $thirdparty->client = $thirdparty::PROSPECT; $thirdparty->fournisseur = 0; - $thirdparty->country_id = GETPOST("country_id", 'int'); - $thirdparty->state_id = GETPOST("state_id", 'int'); + $thirdparty->country_id = GETPOSTINT("country_id"); + $thirdparty->state_id = GETPOSTINT("state_id"); $thirdparty->email = ($emailcompany ? $emailcompany : $email); // Load object modCodeTiers From 0a119e8491f533299a594a497e30c1b26c685197 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 20:15:38 +0100 Subject: [PATCH 34/40] qual: phpstan htdocs/public/project/suggestconference.php 259 Property Societe::$country_id (int) does not accept array|string. htdocs/public/project/suggestconference.php 260 Property CommonObject::$state_id (int) does not accept array|string. --- htdocs/public/project/suggestconference.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/project/suggestconference.php b/htdocs/public/project/suggestconference.php index 328ddffbc51..79a67502eba 100644 --- a/htdocs/public/project/suggestconference.php +++ b/htdocs/public/project/suggestconference.php @@ -256,8 +256,8 @@ if (empty($reshook) && $action == 'add') { $thirdparty->town = GETPOST("town"); $thirdparty->client = $thirdparty::PROSPECT; $thirdparty->fournisseur = 0; - $thirdparty->country_id = GETPOST("country_id", 'int'); - $thirdparty->state_id = GETPOST("state_id", 'int'); + $thirdparty->country_id = GETPOSTINT("country_id"); + $thirdparty->state_id = GETPOSTINT("state_id"); $thirdparty->email = ($emailcompany ? $emailcompany : $email); // Load object modCodeTiers From 070478c750c667dd34761e110deb71499cf88a30 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 20:21:20 +0100 Subject: [PATCH 35/40] qual: phpstan htdocs/reception/card.php 617 Property CommandeFournisseurDispatch::$id (int) does not accept array|string. htdocs/reception/card.php 659 Property CommandeFournisseurDispatch::$id (int) does not accept array|string. htdocs/reception/card.php 660 Property CommandeFournisseurDispatch::$fk_entrepot (int) does not accept array|string. htdocs/reception/card.php 685 Property CommandeFournisseurDispatch::$id (int) does not accept array|string. --- htdocs/reception/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 1115ef085f1..a4d4c666377 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -83,7 +83,7 @@ if (empty($origin_id)) { $origin_id = GETPOST('originid', 'int'); // Id of order or propal } $ref = GETPOST('ref', 'alpha'); -$line_id = GETPOST('lineid', 'int') ? GETPOST('lineid', 'int') : ''; +$line_id = GETPOSTINT('lineid') ? GETPOSTINT('lineid') : 0; $facid = GETPOST('facid', 'int'); $action = GETPOST('action', 'alpha'); @@ -657,7 +657,7 @@ if (empty($reshook)) { $line->id = $line_id; - $line->fk_entrepot = GETPOST($stockLocation, 'int'); + $line->fk_entrepot = GETPOSTINT($stockLocation); $line->qty = GETPOST($qty, 'int'); $line->comment = GETPOST($comment, 'alpha'); From f5d6c65c79365f3be9d4e563bac0f74570d97d0b Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 20:25:54 +0100 Subject: [PATCH 36/40] qual: phpstan htdocs/salaries/paiement_salary.php 113 Property PaymentSalary::$fk_typepayment (int) does not accept array|string. --- htdocs/salaries/paiement_salary.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/salaries/paiement_salary.php b/htdocs/salaries/paiement_salary.php index bc7c81e3e80..3d8e9caf355 100644 --- a/htdocs/salaries/paiement_salary.php +++ b/htdocs/salaries/paiement_salary.php @@ -110,7 +110,7 @@ if (($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == ' $paiement->chid = $id; // deprecated $paiement->datep = $datepaye; $paiement->amounts = $amounts; // Tableau de montant - $paiement->fk_typepayment = GETPOST("paiementtype", 'alphanohtml'); + $paiement->fk_typepayment = GETPOSTINT("paiementtype"); $paiement->num_payment = GETPOST("num_payment", 'alphanohtml'); $paiement->note = GETPOST("note", 'restricthtml'); $paiement->note_private = GETPOST("note", 'restricthtml'); From 704caa4261a605db9af6a2850dfe254433441dd6 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 20:31:29 +0100 Subject: [PATCH 37/40] qual: phpstan htdocs/salaries/class/salary.class.php 317 Property Salary::$fk_user (int) does not accept string. htdocs/salaries/class/salary.class.php 325 Property Salary::$fk_bank (int) does not accept string. htdocs/salaries/class/salary.class.php 326 Property Salary::$fk_user_author (int) does not accept string. htdocs/salaries/class/salary.class.php 327 Property Salary::$fk_user_modif (int) does not accept string. --- htdocs/salaries/class/salary.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index 43fac6af89f..bf3af9539d1 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -314,7 +314,7 @@ class Salary extends CommonObject $this->id = 0; $this->tms = ''; - $this->fk_user = ''; + $this->fk_user = 0; $this->datep = ''; $this->datev = ''; $this->amount = ''; @@ -322,9 +322,9 @@ class Salary extends CommonObject $this->datesp = ''; $this->dateep = ''; $this->note = ''; - $this->fk_bank = ''; - $this->fk_user_author = ''; - $this->fk_user_modif = ''; + $this->fk_bank = 0; + $this->fk_user_author = 0; + $this->fk_user_modif = 0; } /** From aafe309b5814de27a6aced88a507747463b25878 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 21:05:51 +0100 Subject: [PATCH 38/40] Update payment.php - num_payment can be string => GETPOST with alphanohtml --- htdocs/loan/payment/payment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index 1cfdc7aa477..b2d22fbd1b7 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -154,7 +154,7 @@ if ($action == 'add_payment') { $payment->amount_interest = $pay_amount_interest; $payment->fk_bank = GETPOSTINT('accountid'); $payment->paymenttype = GETPOST('paymenttype', 'int'); - $payment->num_payment = GETPOSTINT('num_payment'); + $payment->num_payment = GETPOST('num_payment', 'alphanohtml'); $payment->note_private = GETPOST('note_private', 'restricthtml'); $payment->note_public = GETPOST('note_public', 'restricthtml'); From 1f7c183301d59e55415622b1e29c315680401aa8 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 19 Jan 2024 21:16:08 +0100 Subject: [PATCH 39/40] Update paymentloan.class.php - $numpayment is string (not int) --- htdocs/loan/class/paymentloan.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 08346ad502b..f9a5a119411 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -77,7 +77,7 @@ class PaymentLoan extends CommonObject public $fk_typepayment; /** - * @var int Payment ID + * @var string Payment ID (ex: 12345-chq1) */ public $num_payment; From 72f2547422f0281f3c8b7876ca117aabfd06b75e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 20 Jan 2024 00:46:02 +0100 Subject: [PATCH 40/40] Update dolresource.class.php --- htdocs/resource/class/dolresource.class.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index bdb0a126f18..b835aefb480 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -374,7 +374,7 @@ class Dolresource extends CommonObject $error++; } } - } + }diction } if (!$error) { @@ -655,14 +655,13 @@ class Dolresource extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."element_resources SET"; - $sql .= " resource_id=".(isset($this->resource_id) ? $this->resource_id : "null").","; - $sql .= " resource_type=".(isset($this->resource_type) ? "'".$this->db->escape($this->resource_type)."'" : "null").","; - $sql .= " element_id=".(isset($this->element_id) ? $this->element_id : "null").","; - $sql .= " element_type=".(isset($this->element_type) ? "'".$this->db->escape($this->element_type)."'" : "null").","; - $sql .= " busy=".(isset($this->busy) ? $this->busy : "null").","; - $sql .= " mandatory=".(isset($this->mandatory) ? $this->mandatory : "null").","; - $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null'); - + $sql .= " resource_id = ".(isset($this->resource_id) ? (int) $this->resource_id : "null").","; + $sql .= " resource_type = ".(isset($this->resource_type) ? "'".$this->db->escape($this->resource_type)."'" : "null").","; + $sql .= " element_id = ".(isset($this->element_id) ? (int) $this->element_id : "null").","; + $sql .= " element_type = ".(isset($this->element_type) ? "'".$this->db->escape($this->element_type)."'" : "null").","; + $sql .= " busy = ".(isset($this->busy) ? (int) $this->busy : "null").","; + $sql .= " mandatory = ".(isset($this->mandatory) ? (int) $this->mandatory : "null").","; + $sql .= " tms = ".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null'); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin();