From c66f7d634511dac21225c22b03e5c90c40ffa6da Mon Sep 17 00:00:00 2001 From: thibdrev Date: Thu, 7 Mar 2024 18:20:18 +0100 Subject: [PATCH 01/11] qual: phpstan for htdocs/comm/action/class/ical.class.php (#28685) htdocs/comm/action/class/ical.class.php 146 Property ICal::$file_text (string) does not accept null. htdocs/comm/action/class/ical.class.php 171 Property ICal::$file_text (string) does not accept array|false. --- htdocs/comm/action/class/ical.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index 20b34678a5d..258539a8cd8 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -143,7 +143,7 @@ class ICal $this->cal = array(); // new empty array $this->event_count = -1; - $this->file_text = null; + $this->file_text = ''; // Save file into a cache if ($usecachefile) { @@ -168,10 +168,10 @@ class ICal } } - $this->file_text = preg_split("[\n]", $this->file_text); + $file_text_array = preg_split("[\n]", $this->file_text); // is this text vcalendar standard text ? on line 1 is BEGIN:VCALENDAR - if (!stristr($this->file_text[0], 'BEGIN:VCALENDAR')) { + if (!stristr($file_text_array[0], 'BEGIN:VCALENDAR')) { return 'error not VCALENDAR'; } @@ -179,7 +179,7 @@ class ICal $tmpkey = ''; $tmpvalue = ''; $type = ''; - foreach ($this->file_text as $text) { + foreach ($file_text_array as $text) { $text = trim($text); // trim one line if (!empty($text)) { // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin From 61e69b352b7bc955fa8ee3a94cb8b795c34d80c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2024 18:44:55 +0100 Subject: [PATCH 02/11] Doc --- dev/setup/pre-commit/README.md | 13 +++++++------ htdocs/langs/en_US/admin.lang | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dev/setup/pre-commit/README.md b/dev/setup/pre-commit/README.md index 1f3740144c2..c5c35e81829 100644 --- a/dev/setup/pre-commit/README.md +++ b/dev/setup/pre-commit/README.md @@ -23,16 +23,17 @@ the project: `pre-commit-config.yaml`. ### Installation in your git project -1. Install `pre-commit` tool.\ +1. Install pre-commit tool.\ If you do not have python installed, install [python](https://www.python.org) first.\ If you do not have [`pip`](https://pypi.org/project/pip), install that as well.\\ - Then you can install pre-commit tool: `python -m pip install pre-commit`. + Then you can install pre-commit tool: + `python3 -m pip install pre-commit` -2. In your local git clone of the project, run `pre-commit install` to add the hooks.\ - or copy the file git/hooks/pre-commit manually. (recommended because this file differs - from the file installed with pre-commit install as it redirects output to the error - channel so your IDE will be able to catch the error. +2. In your local git clone of the project, run `pre-commit install` to add the hooks + or copy the file *dev/setup/git/hooks/pre-commit* manually into *.git/hooks/pre-commit* + (recommended because this file may differ from the file installed with the pre-commit install). + The good file redirects output to the error channel so your IDE will be able to catch the error. ### Tips diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b7dd42c84e2..e632b93088a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -655,7 +655,7 @@ Module2200Desc=Use maths expressions for auto-generation of prices Module2300Name=Scheduled jobs Module2300Desc=Scheduled jobs management (alias cron or chrono table) Module2400Name=Events/Agenda -Module2400Desc=Track events. Log automatic events for tracking purposes or record manual events or meetings. This is the principal module for good Customer or Vendor Relationship Management. +Module2400Desc=Manage manual and automatic events. Provide a calendar to record events manually. Log also events automatically for tracking purposes or record manual events or meetings. This is the principal module for good Customer or Vendor Relationship Management. Module2430Name=Online appointment scheduling Module2430Desc=Provides an online appointment booking system. This allow anyone to book rendez-vous, according to predefined ranges or availabilities. Module2500Name=DMS / ECM From 9b59445e39b75dd8771a18254b4f7eecda9baaa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 7 Mar 2024 18:48:50 +0100 Subject: [PATCH 03/11] fix unknown $user (#28687) * fix unknown $user * fix @param * fix @param * fix @param * fix @param --- htdocs/fourn/class/fournisseur.commande.class.php | 11 +++++------ htdocs/hrm/class/establishment.class.php | 1 - htdocs/ticket/class/api_tickets.class.php | 3 ++- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b2a5140c9e1..13e43b59165 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2316,6 +2316,8 @@ class CommandeFournisseur extends CommonOrder */ public function deleteLine($idline, $notrigger = 0) { + global $user; + if ($this->statut == 0) { $line = new CommandeFournisseurLigne($this->db); @@ -2333,12 +2335,11 @@ class CommandeFournisseur extends CommonOrder } } - if ($line->delete($notrigger) > 0) { + if ($line->delete($user, $notrigger) > 0) { $this->update_price(1); return 1; } else { - $this->error = $line->error; - $this->errors = $line->errors; + $this->setErrorsFromObject($line); return -1; } } else { @@ -4162,10 +4163,8 @@ class CommandeFournisseurLigne extends CommonOrderLine * @param int $notrigger 1=Disable call to triggers * @return int Return integer <0 if KO, >0 if OK */ - public function delete($notrigger = 0) + public function delete($user, $notrigger = 0) { - global $user; - $error = 0; $this->db->begin(); diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 8acbb128987..37ab22b84a9 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -327,7 +327,6 @@ class Establishment extends CommonObject * Delete record * * @param User $user User making the change - * @param int $id Id of record to delete * @return int Return integer <0 if KO, >0 if OK */ public function delete($user) diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index d89decb1ac7..a9ed23f8d61 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 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 @@ -410,7 +411,7 @@ class Tickets extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$this->ticket->delete($user)) { + if (!$this->ticket->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting ticket'); } From 5f7192f475a49abe09e11db22219247d4f9b5d11 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2024 18:51:20 +0100 Subject: [PATCH 04/11] Fix signature of delete method --- .../eventorganization/class/conferenceorbooth.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index f6f14fdf863..97497ced70a 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -359,13 +359,14 @@ class ConferenceOrBooth extends ActionComm /** * Delete object in database * - * @param int $notrigger false=launch triggers after, true=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param User $user User making the delete + * @param int $notrigger false=launch triggers after, true=disable triggers + * @return int Return integer <0 if KO, >0 if OK */ - public function delete($notrigger = 0) + public function delete($user, $notrigger = 0) { //TODO delete attendees and subscription - return parent::delete($notrigger); + return parent::delete($user, $notrigger); } /** From f396bf1218148d7c322dc63a8d3dbd5e8e7d3e6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2024 18:53:21 +0100 Subject: [PATCH 05/11] Fix compatibility --- htdocs/fourn/class/fournisseur.commande.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b2a5140c9e1..10d946004fd 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -4162,9 +4162,11 @@ class CommandeFournisseurLigne extends CommonOrderLine * @param int $notrigger 1=Disable call to triggers * @return int Return integer <0 if KO, >0 if OK */ - public function delete($notrigger = 0) + public function delete($user, $notrigger = 0) { - global $user; + if (empty($user)) { + global $user; + } $error = 0; From c6333c77829ee2c6b708616a4356e559dc525bd6 Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 7 Mar 2024 18:57:18 +0100 Subject: [PATCH 06/11] Fix: Missing parameter (#28691) # Fix: Missing parameter dol_print_error was missing db parameter --- htdocs/compta/prelevement/create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 930c01db9fe..8102984f3b2 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -258,7 +258,7 @@ if ($sourcetype != 'salary') { $pricetowithdraw = $bprev->SommeAPrelever($type, 'salary'); } if ($nb < 0) { - dol_print_error($bprev->error); + dol_print_error($db, $bprev->error); } print ''; @@ -479,7 +479,7 @@ if ($resql) { } $title = $langs->trans("InvoiceWaitingWithdraw"); $picto = 'bill'; - if ($type =='bank-transfer') { + if ($type == 'bank-transfer') { if ($sourcetype != 'salary') { $title = $langs->trans("InvoiceWaitingPaymentByBankTransfer"); } else { From d79b3ba8ec33af9e498fff4cdefa0561a2ca7c19 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Thu, 7 Mar 2024 18:57:38 +0100 Subject: [PATCH 07/11] qual: phpstan for htdocs/expedition/class/expedition.class.php (#28686) htdocs/expedition/class/expedition.class.php 1245 Property CommonObject::$origin (CommonObject|string) does not accept null. htdocs/expedition/class/expedition.class.php 1438 Property CommonObject::$origin (CommonObject|string) does not accept null. --- htdocs/expedition/class/expedition.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 1079f834024..b9b21899b28 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1242,7 +1242,7 @@ class Expedition extends CommonObject $mouvS = new MouvementStock($this->db); // we do not log origin because it will be deleted - $mouvS->origin = null; + $mouvS->origin = ''; // get lot/serial $lotArray = null; if (isModEnabled('productbatch')) { @@ -1440,7 +1440,7 @@ class Expedition extends CommonObject $mouvS = new MouvementStock($this->db); // we do not log origin because it will be deleted - $mouvS->origin = null; + $mouvS->origin = ''; // get lot/serial $lotArray = $shipmentlinebatch->fetchAll($obj->expeditiondet_id); if (!is_array($lotArray)) { From b55804841fda1c9a15d6b01b0a11a23a92ec0c91 Mon Sep 17 00:00:00 2001 From: Jon Bendtsen Date: Thu, 7 Mar 2024 19:01:38 +0100 Subject: [PATCH 08/11] using note_public since note_private is not working (#28675) Co-authored-by: Jon Bendtsen --- htdocs/adherents/subscription/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 6dba7fa0d93..ad1f0633c96 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -238,7 +238,7 @@ if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'edit') { // Label print ''; print ''; + print ''; // Bank line if (isModEnabled("bank") && (getDolGlobalString('ADHERENT_BANK_USE') || $object->fk_bank)) { @@ -334,7 +334,7 @@ if ($rowid && $action != 'edit') { print ''; // Label - print ''; + print ''; // Bank line if (isModEnabled("bank") && (getDolGlobalString('ADHERENT_BANK_USE') || $object->fk_bank)) { From a63d7e08020d0409a4bf734e9bf41ba1d5e7295b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2024 19:06:08 +0100 Subject: [PATCH 09/11] Fix regression --- htdocs/resource/class/dolresource.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 2a40c0406c5..cce2244df42 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -530,6 +530,8 @@ class Dolresource extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $rowid = $this->id; + $error = 0; $this->db->begin(); From 6e2f1d350aa7aed98606afc521183df4ebc50ab7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2024 19:10:27 +0100 Subject: [PATCH 10/11] Fix position of parameter --- htdocs/expedition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 4fdefef202b..8c259b63e2a 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -506,7 +506,7 @@ if (empty($reshook)) { } } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('expedition', 'supprimer')) { $also_update_stock = (GETPOST('alsoUpdateStock', 'alpha') ? 1 : 0); - $result = $object->delete(0, $also_update_stock); + $result = $object->delete($user, 0, $also_update_stock); if ($result > 0) { header("Location: ".DOL_URL_ROOT.'/expedition/index.php'); exit; From eb12fe65451e2b8d12c04eb167ce440d8fc4f8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 7 Mar 2024 19:11:43 +0100 Subject: [PATCH 11/11] fix create from order (#28660) --- htdocs/fichinter/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index c5d1ad93933..a8301b48558 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2014-2022 Charlene Benke * Copyright (C) 2015-2016 Abbes Bahfir * Copyright (C) 2018-2022 Philippe Grand - * Copyright (C) 2020 Frédéric France + * Copyright (C) 2020-2024 Frédéric France * Copyright (C) 2023 Benjamin Grembi * Copyright (C) 2023-2024 William Mead * @@ -338,7 +338,7 @@ if (empty($reshook)) { if ($product_type == Product::TYPE_SERVICE || getDolGlobalString('FICHINTER_PRINT_PRODUCTS')) { //only services except if config includes products $duration = 3600; // Default to one hour - + $desc = ''; // Predefined products & services if ($lines[$i]->fk_product > 0) { $prod = new Product($db);
'.$langs->trans("Label").''; - print '
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans("Label").''.dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private)).'
'.$langs->trans("Label").''.dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_public)).'