Skip to content

Commit fafa1bb

Browse files
Merge branch '5.0.x' into fix-dlf-search-in-document-loading-clearing
2 parents 9b5029e + e098626 commit fafa1bb

File tree

6 files changed

+36
-31
lines changed

6 files changed

+36
-31
lines changed

Classes/Command/BaseCommand.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -230,29 +230,29 @@ protected function saveToDatabase(Document $document): bool
230230
}
231231

232232
// set identifiers
233-
$document->setProdId($metadata['prod_id'][0] ? : '');
234-
$document->setOpacId($metadata['opac_id'][0] ? : '');
235-
$document->setUnionId($metadata['union_id'][0] ? : '');
233+
$document->setProdId($metadata['prod_id'][0] ?? '');
234+
$document->setOpacId($metadata['opac_id'][0] ?? '');
235+
$document->setUnionId($metadata['union_id'][0] ?? '');
236236

237-
$document->setRecordId($metadata['record_id'][0] ? : ''); // (?) $doc->recordId
238-
$document->setUrn($metadata['urn'][0] ? : '');
239-
$document->setPurl($metadata['purl'][0] ? : '');
240-
$document->setDocumentFormat($metadata['document_format'][0] ? : '');
237+
$document->setRecordId($metadata['record_id'][0] ?? ''); // (?) $doc->recordId
238+
$document->setUrn($metadata['urn'][0] ?? '');
239+
$document->setPurl($metadata['purl'][0] ?? '');
240+
$document->setDocumentFormat($metadata['document_format'][0] ?? '');
241241

242242
// set access
243-
$document->setLicense($metadata['license'][0] ? : '');
244-
$document->setTerms($metadata['terms'][0] ? : '');
245-
$document->setRestrictions($metadata['restrictions'][0] ? : '');
246-
$document->setOutOfPrint($metadata['out_of_print'][0] ? : '');
247-
$document->setRightsInfo($metadata['rights_info'][0] ? : '');
243+
$document->setLicense($metadata['license'][0] ?? '');
244+
$document->setTerms($metadata['terms'][0] ?? '');
245+
$document->setRestrictions($metadata['restrictions'][0] ?? '');
246+
$document->setOutOfPrint($metadata['out_of_print'][0] ?? '');
247+
$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
254-
$document->setVolume($metadata['volume'][0] ? : '');
255-
$document->setVolumeSorting($metadata['volume_sorting'][0] ? : $metadata['mets_order'][0] ? : '');
254+
$document->setVolume($metadata['volume'][0] ?? '');
255+
$document->setVolumeSorting($metadata['volume_sorting'][0] ?? $metadata['mets_order'][0] ?? '');
256256

257257
// Get UID of parent document.
258258
if ($document->getDocumentFormat() === 'METS') {
@@ -290,7 +290,7 @@ protected function getParentDocumentUidForSaving(Document $document): int
290290
// find document object by record_id of parent
291291
$parent = AbstractDocument::getInstance($doc->parentHref, ['storagePid' => $this->storagePid]);
292292

293-
if ($parent->recordId) {
293+
if ($parent && $parent->recordId) {
294294
$parentDocument = $this->documentRepository->findOneByRecordId($parent->recordId);
295295

296296
if ($parentDocument === null) {

Classes/Command/IndexCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private function getDocumentFromUrl($doc, string $url): Document
210210
{
211211
$document = null;
212212

213-
if ($doc->recordId) {
213+
if ($doc and $doc->recordId) {
214214
$document = $this->documentRepository->findOneByRecordId($doc->recordId);
215215
} else {
216216
$document = $this->documentRepository->findOneByLocation($url);

Classes/Common/MetsDocument.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -435,16 +435,18 @@ private function getThumbnail(string $id = '')
435435

436436
$thumbnail = null;
437437

438-
while ($fileGrpThumb = array_shift($fileGrpsThumb)) {
439-
if (empty($id)) {
440-
$thumbnail = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb] ?? null;
441-
} else {
442-
$parentId = $this->smLinks['l2p'][$id][0] ?? null;
443-
$thumbnail = $this->physicalStructureInfo[$parentId]['files'][$fileGrpThumb] ?? null;
444-
}
438+
if (!empty($this->physicalStructure)) {
439+
while ($fileGrpThumb = array_shift($fileGrpsThumb)) {
440+
if (empty($id)) {
441+
$thumbnail = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb] ?? null;
442+
} else {
443+
$parentId = $this->smLinks['l2p'][$id][0] ?? null;
444+
$thumbnail = $this->physicalStructureInfo[$parentId]['files'][$fileGrpThumb] ?? null;
445+
}
445446

446-
if (!empty($thumbnail)) {
447-
break;
447+
if (!empty($thumbnail)) {
448+
break;
449+
}
448450
}
449451
}
450452
return $thumbnail;
@@ -1416,7 +1418,10 @@ protected function magicGetThumbnail(bool $forceReload = false): string
14161418
) {
14171419
$this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->smLinks['l2p'][$strctId][0]]['files'][$fileGrpThumb]);
14181420
break;
1419-
} elseif (!empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb])) {
1421+
} elseif (
1422+
!empty($this->physicalStructure)
1423+
&& !empty($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb])
1424+
) {
14201425
$this->thumbnail = $this->getFileLocation($this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb]);
14211426
break;
14221427
}

Classes/Controller/MetadataController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ private function getMetadata(): array
464464
if ($this->settings['rootline'] < 2) {
465465
// Get current structure's @ID.
466466
$ids = [];
467-
$page = $this->currentDocument->physicalStructure[$this->requestData['page']];
467+
$page = $this->currentDocument->physicalStructure[$this->requestData['page']] ?? [];
468468
if (!empty($page) && !empty($this->currentDocument->smLinks['p2l'][$page])) {
469469
foreach ($this->currentDocument->smLinks['p2l'][$page] as $logId) {
470470
$count = $this->currentDocument->getStructureDepth($logId);

Classes/Controller/OaiPmhController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public function mainAction()
273273
// Delete expired resumption tokens.
274274
$this->deleteExpiredTokens();
275275

276-
switch ($this->parameters['verb']) {
276+
switch ($this->parameters['verb'] ?? null) {
277277
case 'GetRecord':
278278
$this->verbGetRecord();
279279
break;

Classes/Domain/Repository/CollectionRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ public function findCollectionsBySettings(array $settings = []): QueryResultInte
9797

9898
$constraints = [];
9999

100-
if ($settings['collections']) {
100+
if ($settings['collections'] ?? false) {
101101
$constraints[] = $query->in('uid', GeneralUtility::intExplode(',', $settings['collections']));
102102
}
103103

104-
if ($settings['index_name']) {
104+
if ($settings['index_name'] ?? false) {
105105
$constraints[] = $query->in('index_name', $settings['index_name']);
106106
}
107107

0 commit comments

Comments
 (0)