From 3adc7dd2e9b3ac4512d2174da127daa496d7d1af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 24 Feb 2023 16:45:07 +0100 Subject: [PATCH 1/5] set errors from object --- htdocs/adherents/class/adherent.class.php | 3 +-- htdocs/core/class/commonobject.class.php | 17 +++++++++++++++++ htdocs/core/lib/functions.lib.php | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index f8d37ff30ca..01b98f4b200 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1726,8 +1726,7 @@ class Adherent extends CommonObject return -2; } } else { - $this->error = $subscription->error; - $this->errors = $subscription->errors; + $this->setErrorsFromObject($subscription); $this->db->rollback(); return -1; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 26c5beb0b73..e3c3dff2b7c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -669,6 +669,23 @@ abstract class CommonObject } return -1; } + + /** + * setErrorsFromObject + * + * @param CommonObject $object commonobject + * @return void + */ + public function setErrorsFromObject($object) + { + if (!empty($object->error)) { + $this->error = $object->error; + } + if (!empty($object->errors)) { + $this->errors = array_merge($this->errors, $object->errors); + } + } + /** * getTooltipContentArray * diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 66b25f6740f..2c993af7deb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1672,7 +1672,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = if (!array_key_exists($level, $logLevels)) { throw new Exception('Incorrect log level'); } - if ($level > $conf->global->SYSLOG_LEVEL) { + if ($level > getDolGlobalInt('SYSLOG_LEVEL')) { return; } From 2d454d68159646470cb1e96f10329c17b1598f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 24 Feb 2023 16:50:41 +0100 Subject: [PATCH 2/5] set errors from object --- htdocs/comm/action/class/actioncomm.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 9269446c2ab..51ec0986fc7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -742,8 +742,7 @@ class ActionComm extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->setErrorsFromObject($hookmanager); $error++; } } From e4e472b4ffbf1102b9cdcfd822c8b5cfec44f73f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 24 Feb 2023 16:55:26 +0100 Subject: [PATCH 3/5] set errors from object --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index bd42149ea07..892c3f77687 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1175,8 +1175,7 @@ class SupplierProposal extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->setErrorsFromObject($hookmanager); $error++; } } From 652a215a07ffaace796ab0695fe941085764c483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 24 Feb 2023 16:57:39 +0100 Subject: [PATCH 4/5] set errors from object --- htdocs/comm/propal/class/propal.class.php | 3 +-- htdocs/commande/class/commande.class.php | 6 ++---- htdocs/compta/facture/class/facture.class.php | 6 ++---- htdocs/contrat/class/contrat.class.php | 3 +-- htdocs/expensereport/class/expensereport.class.php | 3 +-- htdocs/fichinter/class/fichinter.class.php | 3 +-- htdocs/fourn/class/fournisseur.commande.class.php | 3 +-- 7 files changed, 9 insertions(+), 18 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a285662e7f6..04e81ce1c6a 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1505,8 +1505,7 @@ class Propal extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->setErrorsFromObject($hookmanager); $error++; } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 38e3accc1fb..abff23d19ee 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1279,8 +1279,7 @@ class Commande extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->setErrorsFromObject($hookmanager); $error++; } } @@ -1436,8 +1435,7 @@ class Commande extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->setErrorsFromObject($hookmanager); $error++; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8e3119ff424..9fa6b0e0bc9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1330,8 +1330,7 @@ class Facture extends CommonInvoice $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->setErrorsFromObject($hookmanager); $error++; } } @@ -1465,8 +1464,7 @@ class Facture extends CommonInvoice $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->setErrorsFromObject($hookmanager); $error++; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 48a3e4053a4..ae9be094fea 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2630,8 +2630,7 @@ class Contrat extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $clonedObj, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->setErrorsFromObject($hookmanager); $error++; } } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 30862623810..76a0614da18 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -512,8 +512,7 @@ class ExpenseReport extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->setErrorsFromObject($hookmanager); $error++; } } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 62f05f8750d..da199f42206 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1249,8 +1249,7 @@ class Fichinter extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->setErrorsFromObject($hookmanager); $error++; } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 86be26b17ef..99685ea140c 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1758,8 +1758,7 @@ class CommandeFournisseur extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->errors += $hookmanager->errors; - $this->error = $hookmanager->error; + $this->setErrorsFromObject($hookmanager); $error++; } } From b6089882af30cf856a5dbbde2f7783a0af918c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 24 Feb 2023 17:01:00 +0100 Subject: [PATCH 5/5] set errors from object --- htdocs/adherents/class/adherent.class.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 01b98f4b200..f2e84e5127a 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1789,13 +1789,11 @@ class Adherent extends CommonObject } } else { $error++; - $this->error = $acct->error; - $this->errors = $acct->errors; + $this->setErrorsFromObject($acct); } } else { $error++; - $this->error = $acct->error; - $this->errors = $acct->errors; + $this->setErrorsFromObject($acct); } }