From 2e431468a04bb95093e1750fdbbe48c30e936a10 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Oct 2023 17:24:25 +0200 Subject: [PATCH] FIX #25996 FIX #25997 --- .../project/doc/doc_generic_project_odt.modules.php | 4 +++- htdocs/includes/odtphp/odf.php | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index ffbbefe45da..7259a2859a0 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -1046,7 +1046,7 @@ class doc_generic_project_odt extends ModelePDFProjects ), ); - //Insert reference + // Insert list of objects into the project try { $listlines = $odfHandler->setSegment('projectrefs'); @@ -1122,6 +1122,8 @@ class doc_generic_project_odt extends ModelePDFProjects } $odfHandler->mergeSegment($listlines); } + } catch (OdfExceptionSegmentNotFound $e) { + // Do nothing } catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index e3160b880f9..da0b9d28628 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -9,6 +9,13 @@ class OdfException extends Exception { } +/** + * Class of ODT Exception + */ +class OdfExceptionSegmentNotFound extends Exception +{ +} + /** * Templating class for odt file * You need PHP 5.2 at least @@ -662,7 +669,7 @@ IMG; * Extract the segment and store it into $this->segments[]. Return it for next call. * * @param string $segment Segment - * @throws OdfException + * @throws OdfExceptionSegmentNotFound * @return Segment */ public function setSegment($segment) @@ -674,7 +681,7 @@ IMG; $reg = "#\[!--\sBEGIN\s$segment\s--\](.*)\[!--\sEND\s$segment\s--\]#sm"; $m = array(); if (preg_match($reg, html_entity_decode($this->contentXml), $m) == 0) { - throw new OdfException("'".$segment."' segment not found in the document. The tag [!-- BEGIN xxx --] or [!-- END xxx --] is not present into content file."); + throw new OdfExceptionSegmentNotFound("'".$segment."' segment not found in the document. The tag [!-- BEGIN xxx --] or [!-- END xxx --] is not present into content file."); } $this->segments[$segment] = new Segment($segment, $m[1], $this); return $this->segments[$segment];