From 23ca75c27fa866c13b5461664516e71bc6581863 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 27 Nov 2024 19:03:12 +0100 Subject: [PATCH 01/16] Try to fix phan --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e6953f04578..5969bff770f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: # git commit -a -m "My message" --no-verify # (Recommendation: run git commit -a .. once, then with `--no-verify`) - id: no-commit-to-branch - args: [--branch, develop, --pattern, \d+.0] + args: [--branch, develop, --pattern, \d+.0,--no-color] # This checks that xml files are correct - id: check-xml exclude: | From a810b9be45a4e8f5a17043c64ef7696b9e5688e4 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 27 Nov 2024 19:19:25 +0100 Subject: [PATCH 02/16] Fix precommit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5969bff770f..e6953f04578 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: # git commit -a -m "My message" --no-verify # (Recommendation: run git commit -a .. once, then with `--no-verify`) - id: no-commit-to-branch - args: [--branch, develop, --pattern, \d+.0,--no-color] + args: [--branch, develop, --pattern, \d+.0] # This checks that xml files are correct - id: check-xml exclude: | From e901cbdfa82efeae7080fb29d1c2e42bf050166e Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 27 Nov 2024 20:14:12 +0100 Subject: [PATCH 03/16] Test --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e091cba2db1..930f8cca6cb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1591,7 +1591,7 @@ function dol_clone($object, $native = 2) } /** - * Optimize a size for some browsers (phone, smarphone, ...) + * Optimize a size for some browsers (phone, smarphone...) * * @param int $size Size we want * @param string $type Type of optimizing: From f28928daeb740cc33ce76031fb205519e2061359 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 27 Nov 2024 20:29:04 +0100 Subject: [PATCH 04/16] Test --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 930f8cca6cb..95a301141b1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -122,7 +122,7 @@ if (!function_exists('str_contains')) { /** - * Return the full path of the directory where a module (or an object of a module) stores its files, + * Return the full path of the directory where a module (or an object of a module) stores its files. * Path may depends on the entity if a multicompany module is enabled. * * @param CommonObject $object Dolibarr common object @@ -132,7 +132,7 @@ if (!function_exists('str_contains')) { * @return string|null The path of the relative directory of the module, ending with / * @since Dolibarr V18 */ -function getMultidirOutput($object, $module = '', $forobject = 0, $mode = 'output') +function getMultidirOutput($object, $odule = '', $forobject = 0, $mode = 'output') { global $conf; From 10bc40dbb659428d61c1d4760d792036f883628c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Nov 2024 21:00:49 +0100 Subject: [PATCH 05/16] Update README.md --- dev/setup/pre-commit/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/setup/pre-commit/README.md b/dev/setup/pre-commit/README.md index ab830e9270c..d4bbb8013f5 100644 --- a/dev/setup/pre-commit/README.md +++ b/dev/setup/pre-commit/README.md @@ -96,4 +96,6 @@ CI also runs pre-commit to help maintain code quality. Note: Code for precommits are saved into: +.cache/pre-commit/repo*/pre_commit_hooks/php-*.sh +and .cache/pre-commit/repo*/py_env-python3/lib/python*/site-packages/pre_commit_hooks/no_commit_to_branch.py From 998da221a2f489c42f5ad03a96361f7e12628f92 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 27 Nov 2024 21:03:30 +0100 Subject: [PATCH 06/16] Test --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 95a301141b1..07afd265d8c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2022 Laurent Destailleur + * Copyright (C) 2004-2024 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Christophe Combelles @@ -132,7 +132,7 @@ if (!function_exists('str_contains')) { * @return string|null The path of the relative directory of the module, ending with / * @since Dolibarr V18 */ -function getMultidirOutput($object, $odule = '', $forobject = 0, $mode = 'output') +function getMultidirOutput($object, $module = '', $forobject = 0, $mode = 'output') { global $conf; From 92c1af15a7ed59af3bb55448cf1484cebf724f3c Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 27 Nov 2024 21:03:59 +0100 Subject: [PATCH 07/16] Test --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 07afd265d8c..01e906dbc54 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -125,7 +125,7 @@ if (!function_exists('str_contains')) { * Return the full path of the directory where a module (or an object of a module) stores its files. * Path may depends on the entity if a multicompany module is enabled. * - * @param CommonObject $object Dolibarr common object + * @param CommonObject $object Dolibarr common object. * @param string $module Override object element, for example to use 'mycompany' instead of 'societe' * @param int $forobject Return the more complete path for the given object instead of for the module only. * @param string $mode 'output' (full main dir) or 'outputrel' (relative dir) or 'temp' (for temporary files) or 'version' (dir for archived files) From fbb4c3d0257b5e5ee575dc8bb287ca588af80121 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 27 Nov 2024 21:11:28 +0100 Subject: [PATCH 08/16] Try to fix phan --- htdocs/adherents/class/adherent.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 7ad5ee54ee7..96e9d4f0528 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -830,6 +830,8 @@ class Adherent extends CommonObject $sql .= " WHERE rowid = ".((int) $this->id); // If we change the type of membership, we set also label of new type + '@phan-var-force Adherent $oldcopy'; + /** @var Adherent $oldcopy */ if (!empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) { $sql2 = "SELECT libelle as label"; $sql2 .= " FROM ".MAIN_DB_PREFIX."adherent_type"; From ea9f88a58380be705151a1ab5b808aa77d35c419 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 27 Nov 2024 21:17:51 +0100 Subject: [PATCH 09/16] Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop --- htdocs/comm/action/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index db077fa32a5..475c580400f 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -308,7 +308,7 @@ $title = $langs->trans("Agenda"); llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist'); // Define list of all external calendars -// $listofextcals = array(); Not used yet in lists +// $listofextcals = array(); Not used yet in lists $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { From a6e8fbc89929cf198a5ad04128257c4fd9c3e76e Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 27 Nov 2024 21:26:23 +0100 Subject: [PATCH 10/16] Test --- htdocs/adherents/class/adherent.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 96e9d4f0528..2b28e9487cd 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -830,8 +830,8 @@ class Adherent extends CommonObject $sql .= " WHERE rowid = ".((int) $this->id); // If we change the type of membership, we set also label of new type - '@phan-var-force Adherent $oldcopy'; - /** @var Adherent $oldcopy */ + '@phan-var-force Adherent $this->oldcopy'; + /** @var Adherent $this->oldcopy */ if (!empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) { $sql2 = "SELECT libelle as label"; $sql2 .= " FROM ".MAIN_DB_PREFIX."adherent_type"; From c1d6e0411c548f061e09125b91c78e1e4c6ae80a Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 27 Nov 2024 21:31:14 +0100 Subject: [PATCH 11/16] Test --- htdocs/adherents/class/adherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 2b28e9487cd..ca9dd3b295b 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -829,7 +829,7 @@ class Adherent extends CommonObject $sql .= ", fk_user_mod = ".($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest $sql .= " WHERE rowid = ".((int) $this->id); - // If we change the type of membership, we set also label of new type + // If we change the type of membership, we set also label of new type. '@phan-var-force Adherent $this->oldcopy'; /** @var Adherent $this->oldcopy */ if (!empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) { From 6eb8870992b2709e120eb2a931d0595da25958e6 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 27 Nov 2024 21:35:48 +0100 Subject: [PATCH 12/16] Test --- htdocs/adherents/class/adherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index ca9dd3b295b..ab1287a07dd 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -43,7 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonpeople.class.php'; /** - * Class to manage members of a foundation + * Class to manage members of a foundation. */ class Adherent extends CommonObject { From 13ad68d8bff91fec27143c71c04d2cd19e1f6fdd Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 27 Nov 2024 21:46:16 +0100 Subject: [PATCH 13/16] Try fix phan phpstan --- htdocs/adherents/class/adherent.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index ab1287a07dd..486f1b1295f 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -315,6 +315,11 @@ class Adherent extends CommonObject */ public $invoice; + /** + * @var Adherent To store a copy before update or delete + */ + public $oldcopy; + /** * @var array|string,position:int,notnull?:int,visible:int<-2,5>|string,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array,comment?:string,validate?:int<0,1>}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. @@ -829,9 +834,8 @@ class Adherent extends CommonObject $sql .= ", fk_user_mod = ".($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest $sql .= " WHERE rowid = ".((int) $this->id); - // If we change the type of membership, we set also label of new type. - '@phan-var-force Adherent $this->oldcopy'; - /** @var Adherent $this->oldcopy */ + // If we change the type of membership, we set also label of new type.. + '@phan-var-force Adherent $oldcopy'; if (!empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) { $sql2 = "SELECT libelle as label"; $sql2 .= " FROM ".MAIN_DB_PREFIX."adherent_type"; From 353633cef8e4d5ec614a4ed011f90c03683db702 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Wed, 27 Nov 2024 21:59:20 +0100 Subject: [PATCH 14/16] Revert to use instead #32123 --- htdocs/adherents/class/adherent.class.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 486f1b1295f..95cfbe2e55e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -315,11 +315,6 @@ class Adherent extends CommonObject */ public $invoice; - /** - * @var Adherent To store a copy before update or delete - */ - public $oldcopy; - /** * @var array|string,position:int,notnull?:int,visible:int<-2,5>|string,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array,comment?:string,validate?:int<0,1>}> Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. From 13b8f5feffc4edeaa769507933bb4e1e0936908f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 27 Nov 2024 21:59:41 +0100 Subject: [PATCH 15/16] keep only commonobject property oldcopy (#32123) * clean properties * clean properties * clean properties * clean properties * clean phpcs * clean phan * clean code --------- Co-authored-by: Laurent Destailleur --- build/phpstan/phpstan-baseline.neon | 6 ------ htdocs/asset/class/asset.class.php | 6 ------ htdocs/comm/propal/class/propal.class.php | 5 ----- htdocs/compta/facture/class/facture.class.php | 5 ----- htdocs/contact/class/contact.class.php | 7 ------- htdocs/core/class/comment.class.php | 5 ----- htdocs/core/class/commonobject.class.php | 2 +- htdocs/product/class/product.class.php | 5 ----- htdocs/product/stock/class/productlot.class.php | 4 ---- htdocs/product/stock/movement_list.php | 3 +-- htdocs/projet/class/project.class.php | 5 ----- htdocs/public/payment/newpayment.php | 2 +- htdocs/resource/class/dolresource.class.php | 5 ----- htdocs/societe/class/societe.class.php | 5 ----- htdocs/societe/paymentmodes.php | 6 +++--- htdocs/ticket/class/ticket.class.php | 6 ------ htdocs/user/class/user.class.php | 5 ----- htdocs/user/class/usergroup.class.php | 5 ----- 18 files changed, 6 insertions(+), 81 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index d8806427808..027b03a0df4 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -27870,12 +27870,6 @@ parameters: count: 1 path: ../../htdocs/product/stock/movement_list.php - - - message: '#^Variable \$whClass might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/product/stock/movement_list.php - - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index ca2060ac4b2..6454ef43b84 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -231,12 +231,6 @@ class Asset extends CommonObject */ public $status; - /** - * @var static object oldcopy - */ - public $oldcopy; - - /** * @var AssetDepreciationOptions Used for computed fields of depreciation options class. */ diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index ac6d62da82c..57e8bb3b0b9 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -122,11 +122,6 @@ class Propal extends CommonObject */ public $ref_customer; - /** - * @var static oldcopy with propal properties - */ - public $oldcopy; - /** * Status of the quote * @var int diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e63c86551cc..7f7eb71398b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -248,11 +248,6 @@ class Facture extends CommonInvoice */ public $tab_next_situation_invoice = array(); - /** - * @var static object oldcopy - */ - public $oldcopy; - /** * @var float percentage of retainage */ diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 5fc553e9994..410ea609318 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -343,13 +343,6 @@ class Contact extends CommonObject public $ip; // END MODULEBUILDER PROPERTIES - - /** - * Old copy - * @var static - */ - public $oldcopy; // To contain a clone of this when we need to save old properties of object - /** * @var array roles */ diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index c1e3f61379d..9bb732e0a42 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -76,11 +76,6 @@ class Comment extends CommonObject public $comments = array(); - /** - * @var static Object oldcopy - */ - public $oldcopy; - /** * Constructor diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 66f9af18511..8fe7db58b72 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -177,7 +177,7 @@ abstract class CommonObject private $linkedObjectsFullLoaded = array(); /** - * @var ?mixed To store a cloned copy of the object before editing it (to keep track of its former properties) + * @var ?static To store a cloned copy of the object before editing it (to keep track of its former properties) */ public $oldcopy; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 0eff9ebfbd3..558a6e285b6 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -71,11 +71,6 @@ class Product extends CommonObject */ public $fk_element = 'fk_product'; - /** - * @var static - */ - public $oldcopy; - /** * @var array> List of child tables. To test if we can delete object. */ diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 61e7daeef71..86bd74c9503 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -848,7 +848,6 @@ class Productlot extends CommonObject */ public function loadStatsExpedition($socid = 0) { - // phpcs:enable global $user, $hookmanager, $action; $sql = "SELECT COUNT(DISTINCT exp.fk_soc) as nb_customers, COUNT(DISTINCT exp.rowid) as nb,"; @@ -923,7 +922,6 @@ class Productlot extends CommonObject */ public function loadStatsSupplierOrder($socid = 0) { - // phpcs:enable global $user, $hookmanager, $action; $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,"; @@ -998,7 +996,6 @@ class Productlot extends CommonObject */ public function loadStatsReception($socid = 0) { - // phpcs:enable global $user, $hookmanager, $action; $sql = "SELECT COUNT(DISTINCT recep.fk_soc) as nb_customers, COUNT(DISTINCT recep.rowid) as nb,"; @@ -1072,7 +1069,6 @@ class Productlot extends CommonObject */ public function loadStatsMo($socid = 0) { - // phpcs:enable global $user, $hookmanager, $action; $error = 0; diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 86986da7ed4..e5cabbe26d5 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -333,8 +333,7 @@ if (empty($reshook)) { } if ($action == 'update_extras' && $permissiontoadd) { - $whClass = get_class($whClass); - $whClass::$oldcopy = dol_clone($tmpwarehouse, 2); + $tmpwarehouse->oldcopy = dol_clone($tmpwarehouse, 2); // @phan-suppress-current-line PhanTypeMismatchProperty // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $tmpwarehouse, GETPOST('attribute', 'restricthtml')); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index d1cdb653234..993e6a07e68 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -246,11 +246,6 @@ class Project extends CommonObject */ public $email_msgid; - /** - * @var ?static - */ - public $oldcopy; - /** * @var array Used to store workload details of a projet (array[day]) */ diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index aef2adf13ef..65496011542 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1707,7 +1707,7 @@ if ($source == 'member' || $source == 'membersubscription') { } // - If a new amount was posted from the form if ($caneditamount && GETPOSTISSET('newamount') && GETPOSTFLOAT('newamount', 'MT') > 0) { - $amount = GETPOSTFLOAT('newamount', 'MT'); + $amount = GETPOSTFLOAT('newamount', 'MT'); } // - If a min is set or an amount from the posted form, we take them into account $amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT")); diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 40955b2f77c..75a96e391f6 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -131,11 +131,6 @@ class Dolresource extends CommonObject */ public $cache_code_type_resource; - /** - * @var static Clone of object before changing it - */ - public $oldcopy; - /** * Constructor diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 5c244c10b62..e1e66ac6edf 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -133,11 +133,6 @@ class Societe extends CommonObject */ public $restrictiononfksoc = 1; - /** - * @var static To store a cloned copy of object before to edit it and keep track of old properties - */ - public $oldcopy; - /** * array of supplier categories * @var string[] diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 5e3dfee76c3..595943b5845 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -177,7 +177,7 @@ if (empty($reshook)) { } if (!$error) { - $companybankaccount->oldcopy = dol_clone($companybankaccount, 2); + $companybankaccount->oldcopy = dol_clone($companybankaccount, 2); // @phan-suppress-current-line PhanTypeMismatchProperty $companybankaccount->socid = $object->id; @@ -254,7 +254,7 @@ if (empty($reshook)) { $companypaymentmode->fetch($id); if (!$error) { - $companypaymentmode->oldcopy = dol_clone($companypaymentmode, 2); + $companypaymentmode->oldcopy = dol_clone($companypaymentmode, 2); // @phan-suppress-current-line PhanTypeMismatchProperty $companypaymentmode->fk_soc = $object->id; @@ -311,7 +311,7 @@ if (empty($reshook)) { // Ajout $companybankaccount = new CompanyBankAccount($db); - $companybankaccount->socid = $object->id; + $companybankaccount->socid = $object->id; $companybankaccount->fetch_thirdparty(); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 848abcb4151..56cfb53ef9a 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -246,17 +246,11 @@ class Ticket extends CommonObject */ public $ip; - /** - * @var static Save the ticket before an update operation (for triggers) - */ - public $oldcopy; - /** * @var Ticket[] Array of Tickets */ public $lines; - /** * @var string Regex pour les images */ diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f0b2ea132fa..975cbefb98a 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -75,11 +75,6 @@ class User extends CommonObject */ public $id = 0; - /** - * @var static old copy of User - */ - public $oldcopy; - /** * @var int * @deprecated Use $status diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index e5232ca2e4b..f885c05951d 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -125,11 +125,6 @@ class UserGroup extends CommonObject */ public $all_permissions_are_loaded; - /** - * @var static - */ - public $oldcopy; // To contains a clone of this when we need to save old properties of object - public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'index' => 1, 'position' => 1, 'comment' => 'Id'), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'default' => '1', 'index' => 1, 'position' => 5), From d2d592ebd6236fc825e9c5557b12ab4ad2ddf8e4 Mon Sep 17 00:00:00 2001 From: David Beniamine Date: Wed, 27 Nov 2024 22:03:41 +0100 Subject: [PATCH 16/16] Make sure that thirdparty is actually loaded before using it's country for lang (#32107) --- htdocs/adherents/class/adherent.class.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 95cfbe2e55e..eee7fde0377 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -3105,11 +3105,14 @@ class Adherent extends CommonObject $nbko++; $listofmembersko[$adherent->id] = $adherent->id; } else { - $adherent->fetch_thirdparty(); - - // Language code to use ($languagecodeformember) is default language of thirdparty, if no thirdparty, the language found from country of member then country of thirdparty, and if still not found we use the language of company. - $languagefromcountrycode = getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code); - $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang); + $thirdpartyres = $adherent->fetch_thirdparty(); + if ($thirdpartyres === -1 ) { + $languagecodeformember = $mysoc->default_lang; + } else { + // Language code to use ($languagecodeformember) is default language of thirdparty, if no thirdparty, the language found from country of member then country of thirdparty, and if still not found we use the language of company. + $languagefromcountrycode = getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code); + $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang); + } // Send reminder email $outputlangs = new Translate('', $conf);