From b41020a801f49547d7e3391e088c7636fc550d32 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Wed, 28 Feb 2024 20:05:33 +0100 Subject: [PATCH 01/12] Fix method by changing return type (#28507) * FIX return method getListOfCharacterSet by adding null type * Fix return method getListOfCollation by adding return null --- htdocs/core/db/pgsql.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 1e218d9cd1f..35ce3ff072b 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -1332,7 +1332,7 @@ class DoliDBPgsql extends DoliDB /** * Return list of available charset that can be used to store data in database * - * @return array List of Charset + * @return array|null List of Charset */ public function getListOfCharacterSet() { @@ -1371,7 +1371,7 @@ class DoliDBPgsql extends DoliDB /** * Return list of available collation that can be used for database * - * @return array Liste of Collation + * @return array|null Liste of Collation */ public function getListOfCollation() { From 6c5855c99fd72c36503e0a77d8aa9a1963109eec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Feb 2024 20:07:26 +0100 Subject: [PATCH 02/12] Clean code --- htdocs/core/lib/functions.lib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1619f147c3b..f8357732cef 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2800,7 +2800,7 @@ function dol_bc($var, $moreclass = '') */ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs = null, $mode = 0, $extralangcode = '') { - global $conf, $langs, $hookmanager; + global $langs, $hookmanager; $ret = ''; $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR', 'CN'); // See also MAIN_FORCE_STATE_INTO_ADDRESS @@ -2889,6 +2889,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs * @param int $ts Timestamp (If is_gmt is true, timestamp is already includes timezone and daylight saving offset, if is_gmt is false, timestamp is a GMT timestamp and we must compensate with server PHP TZ) * @param bool $is_gmt See comment of timestamp parameter * @return string A formatted string + * @see dol_stringtotime() */ function dol_strftime($fmt, $ts = false, $is_gmt = false) { @@ -3552,7 +3553,7 @@ function getArrayOfSocialNetworks() */ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetworks = array()) { - global $conf, $user, $langs; + global $user, $langs; $htmllink = $value; From b666d17eede5ac8ab98394796e9a104fb61d72d0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Feb 2024 20:18:35 +0100 Subject: [PATCH 03/12] FIX #28504 --- htdocs/core/class/menubase.class.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 96cf95ceb6a..b86ee41f60f 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -126,12 +126,6 @@ class Menubase */ public $langs; - /** - * @var string Not used - * @deprecated - */ - public $level; - /** * @var string Name family/module for left menu (setup, info, ...) */ @@ -183,7 +177,7 @@ class Menubase */ public function create($user = null) { - global $conf, $langs; + global $conf; // Clean parameters if (!isset($this->enabled)) { @@ -209,9 +203,6 @@ class Menubase if (empty($this->position)) { $this->position = 0; } - if (!$this->level) { - $this->level = 0; - } // Check parameters if (empty($this->menu_handler)) { From aea79e6fbffff769dfaa4d9d4f27f8cdaa7d8e4c Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Wed, 28 Feb 2024 20:21:29 +0100 Subject: [PATCH 04/12] FIX return type of return by adding null in return (#28503) --- htdocs/core/class/lessc.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index 0484968f526..5cfbfe2ed09 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -2281,7 +2281,7 @@ class Lessc * * @param mixed $in Input * @param bool $force Force rebuild? - * @return array lessphp cache structure + * @return array|null lessphp cache structure */ public function cachedCompile($in, $force = false) { From 67d6c988998ca044723ef6b3692a2a914f8993f3 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Wed, 28 Feb 2024 20:22:17 +0100 Subject: [PATCH 05/12] FIX return by adding null (#28502) --- htdocs/core/class/html.formcategory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formcategory.class.php b/htdocs/core/class/html.formcategory.class.php index 5841f5035e1..34a1961bc84 100644 --- a/htdocs/core/class/html.formcategory.class.php +++ b/htdocs/core/class/html.formcategory.class.php @@ -136,7 +136,7 @@ class FormCategory extends Form return $num_rows; } else { dol_print_error($this->db); - return; + return null; } } } From c8f8286fa3f5deb307e76104eef6fe2f20810ab4 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Wed, 28 Feb 2024 20:23:49 +0100 Subject: [PATCH 06/12] Fix return type in howdocuments (#28500) --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index c8589d9b088..5c527e016c2 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -332,7 +332,7 @@ class FormFile * @param int $hideifempty Hide section of generated files if there is no file * @param string $removeaction (optional) The action to remove a file * @param string $tooltipontemplatecombo Text to show on a tooltip after the combo list of templates - * @return string Output string with HTML array of documents (might be empty string) + * @return string|int Output string with HTML array of documents (might be empty string) */ public function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '', $morepicto = '', $object = null, $hideifempty = 0, $removeaction = 'remove_file', $tooltipontemplatecombo = '') { From 946abbfbd1ff943778a6550acefcb644abbd81b9 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Wed, 28 Feb 2024 20:33:36 +0100 Subject: [PATCH 07/12] Fix variable and return in method (#28498) --- htdocs/core/class/html.formsetup.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index d6e0e56f688..32215871529 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -683,7 +683,7 @@ class FormSetupItem $this->fieldValue = getDolGlobalString($this->confKey); return true; } else { - $this->fieldValue = null; + $this->fieldValue = ''; return false; } } @@ -1103,7 +1103,7 @@ class FormSetupItem } elseif (!empty($errors)) { $this->errors[] = $errors; } - return; + return null; } /** From eda3b8e1617874193f775359771611e90b9f6aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 28 Feb 2024 20:36:53 +0100 Subject: [PATCH 08/12] fix phpstan (#28497) --- htdocs/core/class/html.formcompany.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index f142c22c87a..b3be55a633f 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -143,7 +143,7 @@ class FormCompany extends Form * @param int $empty Add empty value in list * @return void */ - public function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0) + public function form_prospect_level($page, $selected = 0, $htmlname = 'prospect_level_id', $empty = 0) { // phpcs:enable global $user, $langs; @@ -195,7 +195,7 @@ class FormCompany extends Form * @param int $empty Add empty value in list * @return void */ - public function formProspectContactLevel($page, $selected = '', $htmlname = 'prospect_contact_level_id', $empty = 0) + public function formProspectContactLevel($page, $selected = 0, $htmlname = 'prospect_contact_level_id', $empty = 0) { global $user, $langs; @@ -643,7 +643,7 @@ class FormCompany extends Form * @param string $morecss More CSS on select component * @return int The selected third party ID */ - public function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '') + public function selectCompaniesForNewContact($object, $var_id, $selected = 0, $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '') { global $conf, $hookmanager; From d4a548a48f664a5f7217a1291827db8b9fd06098 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Wed, 28 Feb 2024 20:57:03 +0100 Subject: [PATCH 09/12] Fix return method select_conditions_paiements (#28495) --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5c8ea19dc73..ce7594a56f1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4323,7 +4323,7 @@ class Form * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) * @param int $noprint if set to one we return the html to print, if 0 (default) we print it - * @return void + * @return void|string * @deprecated */ public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '', $deposit_percent = -1, $noprint = 0) From 32995e3b7306bab263aefbdb890edbc1481d8c92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Feb 2024 21:11:47 +0100 Subject: [PATCH 10/12] Fix #28478 --- htdocs/compta/facture/class/api_invoices.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 2c4995989e1..e86e221bbb7 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1630,9 +1630,9 @@ class Invoices extends DolibarrApi if ($is_multicurrency) { $amounts[$id] = null; // Multicurrency - $multicurrency_amounts[$id] = $amount; + $multicurrency_amounts[$id] = (float) $amount; } else { - $amounts[$id] = $amount; + $amounts[$id] = (float) $amount; // Multicurrency $multicurrency_amounts[$id] = null; } @@ -1644,7 +1644,7 @@ class Invoices extends DolibarrApi $paymentobj->amounts = $amounts; // Array with all payments dispatching with invoice id $paymentobj->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paymentobj->paiementid = $paymentid; - $paymentobj->paiementcode = dol_getIdFromCode($this->db, $paymentid, 'c_paiement', 'id', 'code', 1); + $paymentobj->paiementcode = (string) dol_getIdFromCode($this->db, $paymentid, 'c_paiement', 'id', 'code', 1); $paymentobj->num_payment = $num_payment; $paymentobj->note_private = $comment; $paymentobj->ref_ext = $ref_ext; From 3c1c6f61ff64ea1c254f2887fd61c9b07445c985 Mon Sep 17 00:00:00 2001 From: Mohamed DAOUD Date: Wed, 28 Feb 2024 21:36:16 +0100 Subject: [PATCH 11/12] warnings fix some php warnings (#28467) --- htdocs/website/websiteaccount_card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 6194a540789..8621c398af9 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -209,13 +209,13 @@ if ($action == 'create') { if ($backtopage) { print ''; } - if ($backtopageforcancel) { + if (!empty($backtopageforcancel)) { print ''; } - if ($backtopagejsfields) { + if (!empty($backtopagejsfields)) { print ''; } - if ($dol_openinpopup) { + if (!empty($dol_openinpopup)) { print ''; } From eb6aa92359b6f1e7c7327f13f3b44cb9adb05176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 28 Feb 2024 21:43:23 +0100 Subject: [PATCH 12/12] fix isModEnabled for all case (#28465) * Update conf.class.php * new test * new test * new test * ficheinter not fichinter --- htdocs/core/lib/functions.lib.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f8357732cef..6f47523cc3c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -219,7 +219,7 @@ define( 'entrepot' => 'stock', 'expedition' => 'delivery_note', 'facture' => 'invoice', - 'fichinter' => 'intervention', + 'ficheinter' => 'intervention', 'product_fournisseur_price' => 'productsupplierprice', 'product_price' => 'productprice', 'projet' => 'project', @@ -240,6 +240,7 @@ function isModEnabled($module) // Fix old names (map to new names) $arrayconv = DEPRECATED_MODULE_MAPPING; + $arrayconvbis = array_flip(DEPRECATED_MODULE_MAPPING); if (!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) { // Special cases: both use the same module. @@ -251,8 +252,12 @@ function isModEnabled($module) if (!empty($arrayconv[$module])) { $module_alt = $arrayconv[$module]; } + $module_bis = $module; + if (!empty($arrayconvbis[$module])) { + $module_bis = $arrayconvbis[$module]; + } - return !empty($conf->modules[$module]) || !empty($conf->modules[$module_alt]); + return !empty($conf->modules[$module]) || !empty($conf->modules[$module_alt]) || !empty($conf->modules[$module_bis]); //return !empty($conf->$module->enabled); }