From cfd701fa0165789000ccbb0116af060467bcd838 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sun, 5 Jan 2025 14:51:28 +0100 Subject: [PATCH] [BUGFIX] Fix handling of METS files without physical structure Signed-off-by: Stefan Weil --- Classes/Common/MetsDocument.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index 6403dc766..16f435de7 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -435,16 +435,18 @@ private function getThumbnail(string $id = '') $thumbnail = null; - while ($fileGrpThumb = array_shift($fileGrpsThumb)) { - if (empty($id)) { - $thumbnail = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb] ?? null; - } else { - $parentId = $this->smLinks['l2p'][$id][0] ?? null; - $thumbnail = $this->physicalStructureInfo[$parentId]['files'][$fileGrpThumb] ?? null; - } + if (!empty($this->physicalStructure)) { + while ($fileGrpThumb = array_shift($fileGrpsThumb)) { + if (empty($id)) { + $thumbnail = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb] ?? null; + } else { + $parentId = $this->smLinks['l2p'][$id][0] ?? null; + $thumbnail = $this->physicalStructureInfo[$parentId]['files'][$fileGrpThumb] ?? null; + } - if (!empty($thumbnail)) { - break; + if (!empty($thumbnail)) { + break; + } } } return $thumbnail; @@ -1416,7 +1418,10 @@ protected function magicGetThumbnail(bool $forceReload = false): string ) { $this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->smLinks['l2p'][$strctId][0]]['files'][$fileGrpThumb]); break; - } elseif (!empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb])) { + } elseif ( + !empty($this->physicalStructure) + && !empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb]) + ) { $this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb]); break; }