Skip to content

Commit 411bfb8

Browse files
[BUGFIX] Fix several runtime issues (kitodo#1468)
Signed-off-by: Stefan Weil <sw@weilnetz.de> Co-authored-by: Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
1 parent 5498422 commit 411bfb8

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Classes/Command/BaseCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ protected function saveToDatabase(Document $document, bool $softCommit = false):
247247
$document->setRightsInfo($metadata['rights_info'][0] ?? '');
248248
$document->setStatus(0);
249249

250-
$this->setOwner($metadata['owner'][0]);
250+
$this->setOwner($metadata['owner'][0] ?? '');
251251
$document->setOwner($this->owner);
252252

253253
// set volume data

Classes/Common/Indexer.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ protected static function processLogical(Document $document, array $logicalUnit)
331331
$doc = $document->getCurrentDocument();
332332
$doc->cPid = $document->getPid();
333333
// Get metadata for logical unit.
334-
$metadata = $doc->metadataArray[$logicalUnit['id']];
334+
$metadata = $doc->metadataArray[$logicalUnit['id']] ?? [];
335335
if (!empty($metadata)) {
336336
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey, 'general');
337337
$validator = new DocumentValidator($metadata, explode(',', $extConf['requiredMetadataFields']));
@@ -356,19 +356,19 @@ protected static function processLogical(Document $document, array $logicalUnit)
356356
// There can be only one toplevel unit per UID, independently of backend configuration
357357
$solrDoc->setField('toplevel', $logicalUnit['id'] == $doc->toplevelId ? true : false);
358358
$solrDoc->setField('title', $metadata['title'][0]);
359-
$solrDoc->setField('volume', $metadata['volume'][0]);
359+
$solrDoc->setField('volume', $metadata['volume'][0] ?? '');
360360
// verify date formatting
361361
if(strtotime($metadata['date'][0])) {
362362
$solrDoc->setField('date', self::getFormattedDate($metadata['date'][0]));
363363
}
364364
$solrDoc->setField('record_id', $metadata['record_id'][0]);
365-
$solrDoc->setField('purl', $metadata['purl'][0]);
365+
$solrDoc->setField('purl', $metadata['purl'][0] ?? '');
366366
$solrDoc->setField('location', $document->getLocation());
367367
$solrDoc->setField('urn', $metadata['urn']);
368368
$solrDoc->setField('license', $metadata['license']);
369369
$solrDoc->setField('terms', $metadata['terms']);
370370
$solrDoc->setField('restrictions', $metadata['restrictions']);
371-
$coordinates = json_decode($metadata['coordinates'][0]);
371+
$coordinates = json_decode($metadata['coordinates'][0] ?? '');
372372
if (is_object($coordinates)) {
373373
$feature = (array) $coordinates->features[0];
374374
$geometry = (array) $feature['geometry'];
@@ -518,7 +518,8 @@ private static function processMetadata($document, $metadata, &$solrDoc): array
518518
&& substr($indexName, -8) !== '_sorting'
519519
) {
520520
$solrDoc->setField(self::getIndexFieldName($indexName, $document->getPid()), $data);
521-
if (in_array($indexName, self::$fields['sortables'])) {
521+
if (in_array($indexName, self::$fields['sortables']) &&
522+
in_array($indexName . '_sorting', $metadata)) {
522523
// Add sortable fields to index.
523524
$solrDoc->setField($indexName . '_sorting', $metadata[$indexName . '_sorting'][0]);
524525
}

Classes/Common/MetsDocument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ protected function magicGetThumbnail(): string
16021602
) {
16031603
$this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->smLinks['l2p'][$strctId][0]]['files'][$useGroup]);
16041604
break;
1605-
} elseif (!empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$useGroup])) {
1605+
} elseif (isset($this->physicalStructure[1]) && !empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$useGroup])) {
16061606
$this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$useGroup]);
16071607
break;
16081608
}

0 commit comments

Comments
 (0)