From 95da30a224247faa1ff30007bfa797c8f6676d08 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 10 Jan 2024 16:41:39 +0100 Subject: [PATCH 1/8] Fix: files.lib.php - Add optional sort parameter to array_multisort for static tool check (#27340) # Fix: files.lib.php - Add optional sort parameter to array_multisort for static tool check Phan flags the call to array_multisort as suspicious - adding the optional sort parameter avoids this. --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index f271fe5505b..6b4b56e1475 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -292,7 +292,7 @@ function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $s } // Sort the data if ($sortorder) { - array_multisort($myarray, $sortorder, $file_list); + array_multisort($myarray, $sortorder, SORT_REGULAR, $file_list); } } From da0bebc9ae1065640bd1fe1c638012f3ee84b191 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 10 Jan 2024 16:56:40 +0100 Subject: [PATCH 2/8] Fix: formmail - add_attached_files - argument name consistency (#27338) # Fix: formmail - add_attached_files - argument name consistency Phan determined suspicious naming as arg #2 to add_attached_files is while that was the name for the first argument by the caller. Also, on examination, only the first parameter is needed as add_attached_files handles the other two in the same manner. --- htdocs/core/class/html.formmail.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 59effb1deac..739223a5c66 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -440,9 +440,9 @@ class FormMail extends Form if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelselected') && GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) { if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param['fileinit']) && is_array($this->param['fileinit'])) { - foreach ($this->param['fileinit'] as $file) { - if (!empty($file)) { - $this->add_attached_files($file, basename($file), dol_mimetype($file)); + foreach ($this->param['fileinit'] as $path) { + if (!empty($path)) { + $this->add_attached_files($path); } } } From 893538d851f45de718478ecb0f9aad375f5fd0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 10 Jan 2024 16:57:30 +0100 Subject: [PATCH 3/8] fix #27313 (#27325) * fix #27313 * Update fichinter.class.php --- htdocs/fichinter/class/fichinter.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 36353fa39e7..8477e4f49ce 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -526,7 +526,7 @@ class Fichinter extends CommonObject dol_syslog(get_class($this)."::setDraft", LOG_DEBUG); - $this->oldcopy = dol_clone($this); + $this->oldcopy = dol_clone($this, 2); $this->db->begin(); From 963afede5e47af6420dee09c88e85ca8aca21133 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 10 Jan 2024 17:38:23 +0100 Subject: [PATCH 4/8] Fix: Match local variable name to parameter variable name (#27316) # Fix: Match local variable name to parameter variable name Improve consistency and avoids that phan reports suspicious parameter order --- htdocs/commande/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6d1821472c0..7ec8ef72b69 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1978,13 +1978,13 @@ if ($action == 'create' && $usercancreate) { print ''; print ''; $incoterm_id = GETPOST('incoterm_id'); - $incoterm_location = GETPOST('location_incoterms'); + $location_incoterms = GETPOST('location_incoterms'); if (empty($incoterm_id)) { $incoterm_id = (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : $soc->fk_incoterms); - $incoterm_location = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms); + $location_incoterms = (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : $soc->location_incoterms); } print img_picto('', 'incoterm', 'class="pictofixedwidth"'); - print $form->select_incoterms($incoterm_id, $incoterm_location); + print $form->select_incoterms($incoterm_id, $location_incoterms); print ''; } From a4030d145a692d7c0908798d513d088c7069cf21 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Jan 2024 17:40:28 +0100 Subject: [PATCH 5/8] FIX #27315 --- htdocs/compta/bank/transfer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 7ef137de862..4ccff71443f 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -189,10 +189,10 @@ if ($action == 'add' && $user->hasRight('banque', 'transfer')) { $error++; } if (!$error) { - $mesgs = $langs->trans("TransferFromToDone", '{s1}', '{s2}', $amount[$n], $langs->transnoentitiesnoconv("Currency".$conf->currency)); - $mesgs = str_replace('{s1}', ''.$tmpaccountfrom->label.'', $mesgs); - $mesgs = str_replace('{s2}', ''.$tmpaccountto->label.'', $mesgs); - setEventMessages($mesgs, null, 'mesgs'); + $mesg = $langs->trans("TransferFromToDone", '{s1}', '{s2}', $amount[$n], $langs->transnoentitiesnoconv("Currency".$conf->currency)); + $mesg = str_replace('{s1}', ''.$tmpaccountfrom->label.'', $mesgs); + $mesg = str_replace('{s2}', ''.$tmpaccountto->label.'', $mesgs); + setEventMessages($mesg, null, 'mesgs'); } else { $error++; setEventMessages($tmpaccountfrom->error.' '.$tmpaccountto->error, null, 'errors'); From 412f8406dde1c9148ce2923d872be6432384cd63 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 10 Jan 2024 22:10:13 +0100 Subject: [PATCH 6/8] Fix: Change TCPDF::_out to public because of pdf.lib.php (#27333) # Fix: Change TCPDF::_out to public because of pdf.lib.php TCPDF::_out is used 2 times as ->_out(...) in htdocs/core/lib/pdf.lib.php. Changing php.lib.php requires more analysis. Making TCPDF::_out public is the quick solution. --- dev/dolibarr_changes.txt | 14 ++++++++++++++ htdocs/includes/tecnickcom/tcpdf/tcpdf.php | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index a87d5de3207..6b00d5243b9 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -73,6 +73,20 @@ NUSOAP: TCPDF: ------ +* Modify in tcpdf.php: make TCPDF::_out public. + (htdocs/core/lib/pdf.lib.php uses it as a public method) + + Change: + protected function _out($s) + to + public function _out($s) + + Change in method's _out phpdoc: + + * @protected + to + * @public + * Replace in tcpdf.php: if (isset($this->imagekeys)) { foreach($this->imagekeys as $file) { diff --git a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php index a1f7453294d..067da52db37 100644 --- a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php +++ b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php @@ -10516,9 +10516,9 @@ class TCPDF /** * Output a string to the document. * @param $s (string) string to output. - * @protected + * @public */ - protected function _out($s) + public function _out($s) { if ($this->state == 2) { if ($this->inxobj) { From 77a922a72e457cf25888f6c0d4a760f7260b02c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Jan 2024 01:41:13 +0100 Subject: [PATCH 7/8] Debug v19 --- htdocs/modulebuilder/index.php | 3 ++- .../{functionnal => functional}/MyModuleFunctionalTest.php | 0 2 files changed, 2 insertions(+), 1 deletion(-) rename htdocs/modulebuilder/template/test/phpunit/{functionnal => functional}/MyModuleFunctionalTest.php (100%) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index fe5d5f42362..2b5e6ba6fc8 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -280,6 +280,7 @@ if ($dirins && $action == 'initmodule' && $modulename) { } // Delete dir and files that can be generated in sub tabs later if we need them (we want a minimal module first) + dol_delete_dir_recursive($destdir.'/ajax'); dol_delete_dir_recursive($destdir.'/build/doxygen'); dol_delete_dir_recursive($destdir.'/core/modules/mailings'); dol_delete_dir_recursive($destdir.'/core/modules/'.strtolower($modulename)); @@ -311,7 +312,7 @@ if ($dirins && $action == 'initmodule' && $modulename) { dol_delete_file($destdir.'/myobject_agenda.php'); dol_delete_file($destdir.'/myobject_list.php'); dol_delete_file($destdir.'/lib/'.strtolower($modulename).'_myobject.lib.php'); - dol_delete_file($destdir.'/test/phpunit/functionnal/'.$modulename.'FunctionnalTest.php'); + dol_delete_file($destdir.'/test/phpunit/functional/'.$modulename.'FunctionalTest.php'); dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); dol_delete_file($destdir.'/sql/llx_'.strtolower($modulename).'_myobject.sql'); dol_delete_file($destdir.'/sql/llx_'.strtolower($modulename).'_myobject_extrafields.sql'); diff --git a/htdocs/modulebuilder/template/test/phpunit/functionnal/MyModuleFunctionalTest.php b/htdocs/modulebuilder/template/test/phpunit/functional/MyModuleFunctionalTest.php similarity index 100% rename from htdocs/modulebuilder/template/test/phpunit/functionnal/MyModuleFunctionalTest.php rename to htdocs/modulebuilder/template/test/phpunit/functional/MyModuleFunctionalTest.php From 11f457ddc89d247e677dabd246f6240708728732 Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 11 Jan 2024 10:47:05 +0100 Subject: [PATCH 8/8] # Fix: remove parameter in getSelectInvoiceSubtype call (#27314) Parameters were already invalid when this was added in 65b9f4e6defe. See https://github.com/Dolibarr/dolibarr/blob/65b9f4e6defede20d488e62f11083c4c0ef5d20b/htdocs/core/class/html.form.class.php#L10865C59-L10865C59 . --- htdocs/compta/facture/card-rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index d4690561632..bb3c6938396 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1006,7 +1006,7 @@ if ($action == 'create') { // Invoice subtype if (getDolGlobalInt('INVOICE_SUBTYPE_ENABLED')) { print "".$langs->trans("InvoiceSubtype").""; - print $form->getSelectInvoiceSubtype(GETPOSTISSET('subtype') ? GETPOST('subtype') : $object->subtype, 'subtype', -1, 0, 0, ''); + print $form->getSelectInvoiceSubtype(GETPOSTISSET('subtype') ? GETPOST('subtype') : $object->subtype, 'subtype', 0, 0, ''); print ""; }