diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index f8d37ff30ca..f2e84e5127a 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; } @@ -1790,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); } } 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++; } } 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/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; } 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++; } } 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++; } }