Merge pull request #24039 from frederic34/setErrorsFromObject

set errors from object
This commit is contained in:
Laurent Destailleur 2023-02-24 17:54:49 +01:00 committed by GitHub
commit f496d4887c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 32 additions and 29 deletions

View File

@ -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);
}
}

View File

@ -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++;
}
}

View File

@ -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++;
}
}

View File

@ -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++;
}

View File

@ -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++;
}

View File

@ -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++;
}
}

View File

@ -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
*

View File

@ -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;
}

View File

@ -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++;
}
}

View File

@ -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++;
}
}

View File

@ -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++;
}
}

View File

@ -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++;
}
}