From cfd88cb6e5cc48b343cea190998aa8a4a681e1d1 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 25 Oct 2021 21:50:27 +0200 Subject: [PATCH] fix scrutinizer error --- .../societe/doc/doc_generic_odt.modules.php | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 8b8069ff34f..6427a6a60a3 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -320,17 +320,22 @@ class doc_generic_odt extends ModeleThirdPartyDoc foreach ($contact_arrray as $array_key => $contact_id) { $res_contact = $contactstatic->fetch($contact_id); - $tmparray = $this->get_substitutionarray_contact($contactstatic, $outputlangs, 'contact'); - foreach ($tmparray as $key => $val) { - try { - $listlines->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); - } catch (SegmentException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + if ((int) $res_contact > 0) { + $tmparray = $this->get_substitutionarray_contact($contactstatic, $outputlangs, 'contact'); + foreach ($tmparray as $key => $val) { + try { + $listlines->setVars($key, $val, true, 'UTF-8'); + } catch (OdfException $e) { + dol_syslog($e->getMessage(), LOG_INFO); + } catch (SegmentException $e) { + dol_syslog($e->getMessage(), LOG_INFO); + } } + $listlines->merge(); + } else { + $this->error = $contactstatic->error; + dol_syslog($this->error, LOG_WARNING); } - $listlines->merge(); } $odfHandler->mergeSegment($listlines); } catch (OdfException $e) {