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); $keymin = strtolower($key);
$i = (int) preg_replace('/[^0-9]/', '', $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; $vallabel = $this->thirdparty->$keymin;
if ($i > 0) 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 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 ErrorAParameterIsRequiredForThisOperation=A parameter is mandatory for this operation
ErrorYouMustFirstSetupYourChartOfAccount=You must first setup your chart of account 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 # Warnings
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.