From 002c2b0abed818b21c45000017a437d5ae55bf3e Mon Sep 17 00:00:00 2001 From: Gerhard Stephan Date: Mon, 24 Apr 2023 14:11:06 +0200 Subject: [PATCH 1/3] Prevent PHP Warning in error log file, when the generated doc file does not exists. This is the case when we create a PDF file out of a ODT file and automatically delete the ODT. The indexed file will then be the ODT, which can't be found on drive (because it has been deleted when converting to PDF) and therefore creates an error log entry. --- htdocs/core/class/commonobject.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index de8f758d8e4..aedabc79cc6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5671,7 +5671,11 @@ abstract class CommonObject $update_main_doc_field = 1; } - $this->indexFile($destfull, $update_main_doc_field); + // Check that the file exists, before indexing it. + // Hint: It does not exist, if we create a PDF and auto delete the ODT File + if (file_exists($destfull)) { + $this->indexFile($destfull, $update_main_doc_field); + } } else { dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING); } From 799f8c5d125ec867c3e530e447a08ad7c8254b68 Mon Sep 17 00:00:00 2001 From: Gerhard Stephan Date: Mon, 24 Apr 2023 18:35:43 +0200 Subject: [PATCH 2/3] Remove whitespace at the end of the line --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index aedabc79cc6..a214c98d0ce 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5671,7 +5671,7 @@ abstract class CommonObject $update_main_doc_field = 1; } - // Check that the file exists, before indexing it. + // Check that the file exists, before indexing it. // Hint: It does not exist, if we create a PDF and auto delete the ODT File if (file_exists($destfull)) { $this->indexFile($destfull, $update_main_doc_field); From 6657a34ff09eb8c28f254b703f66caef43e77e6a Mon Sep 17 00:00:00 2001 From: BitKFu Date: Tue, 25 Apr 2023 19:07:35 +0200 Subject: [PATCH 3/3] use dol_is_file instead of file_exists --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a214c98d0ce..7d2e90f593e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5673,7 +5673,7 @@ abstract class CommonObject // Check that the file exists, before indexing it. // Hint: It does not exist, if we create a PDF and auto delete the ODT File - if (file_exists($destfull)) { + if (dol_is_file($destfull)) { $this->indexFile($destfull, $update_main_doc_field); } } else {