FIX check thirdparty object loaded and properties exist

This commit is contained in:
lvessiller 2022-03-25 16:47:41 +01:00
parent 19ad231012
commit 8a7b97bed1
2 changed files with 17 additions and 1 deletions

View File

@ -2518,6 +2518,20 @@ class Facture extends CommonInvoice
{
$keymin = strtolower($key);
$i = (int) preg_replace('/[^0-9]/', '', $key);
if ($i == 1) {
if (!is_object($this->thirdparty)) {
$langs->load('errors');
$this->error = $langs->trans('ErrorInvoiceLoadThirdParty', $this->ref);
dol_syslog(__METHOD__.' '.$this->error, LOG_ERR);
return -1;
}
}
if (!property_exists($this->thirdparty, $keymin)) {
$langs->load('errors');
$this->error = $langs->trans('ErrorInvoiceLoadThirdPartyKey', $keymin, $this->ref);
dol_syslog(__METHOD__.' '.$this->error, LOG_ERR);
return -1;
}
$vallabel = $this->thirdparty->$keymin;
if ($i > 0)

View File

@ -257,6 +257,8 @@ ErrorLanguageRequiredIfPageIsTranslationOfAnother=The language of new page must
ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother=The language of new page must not be the source language if it is set as a translation of another page
ErrorAParameterIsRequiredForThisOperation=A parameter is mandatory for this operation
ErrorYouMustFirstSetupYourChartOfAccount=You must first setup your chart of account
ErrorInvoiceLoadThirdParty=Can't load third-party object for invoice "%s"
ErrorInvoiceLoadThirdPartyKey=Third-party key "%s" no set for invoice "%s"
# Warnings
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
@ -289,4 +291,4 @@ WarningFailedToAddFileIntoDatabaseIndex=Warning, failed to add file entry into E
WarningTheHiddenOptionIsOn=Warning, the hidden option <b>%s</b> is on.
WarningCreateSubAccounts=Warning, you can't create directly a sub account, you must create a third party or an user and assign them an accounting code to find them in this list
WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connection.
WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here.
WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here.