Skip to content

Commit

Permalink
[BUGFIX] Adjust NULL checks so they also check for non-existent key a…
Browse files Browse the repository at this point in the history
…rrays

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Jan 5, 2025
1 parent 715c91c commit ef2cc30
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions Classes/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,29 +230,29 @@ protected function saveToDatabase(Document $document): bool
}

// set identifiers
$document->setProdId($metadata['prod_id'][0] ? : '');
$document->setOpacId($metadata['opac_id'][0] ? : '');
$document->setUnionId($metadata['union_id'][0] ? : '');
$document->setProdId($metadata['prod_id'][0] ?? '');
$document->setOpacId($metadata['opac_id'][0] ?? '');
$document->setUnionId($metadata['union_id'][0] ?? '');

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

// set access
$document->setLicense($metadata['license'][0] ? : '');
$document->setTerms($metadata['terms'][0] ? : '');
$document->setRestrictions($metadata['restrictions'][0] ? : '');
$document->setOutOfPrint($metadata['out_of_print'][0] ? : '');
$document->setRightsInfo($metadata['rights_info'][0] ? : '');
$document->setLicense($metadata['license'][0] ?? '');
$document->setTerms($metadata['terms'][0] ?? '');
$document->setRestrictions($metadata['restrictions'][0] ?? '');
$document->setOutOfPrint($metadata['out_of_print'][0] ?? '');
$document->setRightsInfo($metadata['rights_info'][0] ?? '');
$document->setStatus(0);

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

// set volume data
$document->setVolume($metadata['volume'][0] ? : '');
$document->setVolumeSorting($metadata['volume_sorting'][0] ? : $metadata['mets_order'][0] ? : '');
$document->setVolume($metadata['volume'][0] ?? '');
$document->setVolumeSorting($metadata['volume_sorting'][0] ?? $metadata['mets_order'][0] ?? '');

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

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

if ($parentDocument === null) {
Expand Down

0 comments on commit ef2cc30

Please sign in to comment.