From 08b4d256ecb3ea904ef1a1f52ae9c65474ed29ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 26 Aug 2024 12:33:03 +0200 Subject: [PATCH] fix: Fix missing conflicts on pdf templating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Service/TemplateFieldService.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/Service/TemplateFieldService.php b/lib/Service/TemplateFieldService.php index 5e0aafb529..4037acf9a1 100644 --- a/lib/Service/TemplateFieldService.php +++ b/lib/Service/TemplateFieldService.php @@ -46,12 +46,16 @@ public function extractFields(Node|int $file): array { } try { + if (!$file || !$file instanceof File) { + throw new NotFoundException(); + } + $localCache = $this->cacheFactory->createLocal('richdocuments_templates/'); $cacheName = $file->getId() . "/" . $file->getEtag(); $cachedResponse = $localCache->get($cacheName); - + if ($cachedResponse !== null) { - // return $cachedResponse; + return $cachedResponse; } if ($file->getMimeType() === 'application/pdf') { @@ -125,6 +129,13 @@ public function fillFields(Node|int $file, array $fields = [], ?string $destinat $file = $this->rootFolder->getFirstNodeById($file); } + if (!$file || !$file instanceof File) { + $e = new NotFoundException(); + $this->logger->error($e->getMessage()); + + throw $e; + } + if ($file->getMimeType() === 'application/pdf') { $content = $this->pdfService->fillFields($file, $fields); if ($destination !== null) {