From 9efd1319bd4ef9946683751035a1e781a38cce11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Sch=C3=B6lzel?= Date: Mon, 30 Dec 2024 17:02:06 +0100 Subject: [PATCH] [BUGFIX] check for undefined array key for fileGrp in mets:fileSec --- Classes/Controller/ToolboxController.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Classes/Controller/ToolboxController.php b/Classes/Controller/ToolboxController.php index cb93c6d62..ee2fb3542 100644 --- a/Classes/Controller/ToolboxController.php +++ b/Classes/Controller/ToolboxController.php @@ -321,14 +321,18 @@ private function renderImageDownloadTool(): void private function getFile(int $page, array $fileGrps): array { $file = []; + $physicalStructureInfo = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$page]] ?? null; while ($fileGrp = @array_pop($fileGrps)) { - $physicalStructureInfo = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$page]]; - $fileId = $physicalStructureInfo['files'][$fileGrp]; - if (!empty($fileId)) { - $file['url'] = $this->currentDocument->getDownloadLocation($fileId); - $file['mimetype'] = $this->currentDocument->getFileMimeType($fileId); + if (isset($physicalStructureInfo['files'][$fileGrp])) { + $fileId = $physicalStructureInfo['files'][$fileGrp]; + if (!empty($fileId)) { + $file['url'] = $this->currentDocument->getDownloadLocation($fileId); + $file['mimetype'] = $this->currentDocument->getFileMimeType($fileId); + } else { + $this->logger->warning('File not found in fileGrp "' . $fileGrp . '"'); + } } else { - $this->logger->warning('File not found in fileGrp "' . $fileGrp . '"'); + $this->logger->warning('fileGrp "' . $fileGrp . '" not found in Document mets:fileSec'); } } return $file;