Skip to content

Commit

Permalink
Fix variable assignment and initialize $links array before use
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed Jun 27, 2024
1 parent 63a8872 commit 3977b56
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Classes/Hooks/KitodoProductionHacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ public function postProcessRecordId(\SimpleXMLElement &$xml, &$recordId): void
if (!$recordId) {
$xml->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3');
// Get all logical structure nodes with metadata, but without associated METS-Pointers.
if (($divs = $xml->xpath('//mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'))) {
$divs = $xml->xpath('//mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]');
if (is_array($divs)) {
$smLinks = $xml->xpath('//mets:structLink/mets:smLink');
if (!empty($smLinks)) {
$links = [];

foreach ($smLinks as $smLink) {
$links[(string) $smLink->attributes('http://www.w3.org/1999/xlink')->from][] = (string) $smLink->attributes('http://www.w3.org/1999/xlink')->to;
}

foreach ($divs as $div) {
if (!empty($links[(string) $div['ID']])) {
$id = (string) $div['DMDID'];
Expand Down

0 comments on commit 3977b56

Please sign in to comment.