Bug 40017: (follow-up) More rigorous checking

Adding a few checks to resolve the errors David found while
testing.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Marcel de Rooy 2025-06-02 11:00:31 +02:00 committed by Lucas Gass
parent 3e2a9aef93
commit 72336b36c5
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 5 additions and 3 deletions

View File

@ -379,10 +379,10 @@ sub _add_custom_field_rowdata {
warn "Breeding: invalid expression in AdditionalFieldsInZ3950Result(Auth)Search: $field";
next;
} elsif ( $tag eq '000' ) {
push @content, ( _extract_positions( $record->leader, $add_spec ) );
push @content, ( _extract_positions( $record->leader, $add_spec ) ) if $record->leader;
} elsif ( $tag =~ /^00\d$/ ) { # control field
my $marcfield = $record->field($tag);
push @content, ( _extract_positions( $marcfield->data, $add_spec ) );
push @content, ( _extract_positions( $marcfield->data, $add_spec ) ) if $marcfield;
} else {
for my $marcfield ( $record->field($tag) ) {
foreach my $subfield ( $marcfield->subfields ) {
@ -402,7 +402,9 @@ sub _add_custom_field_rowdata {
sub _extract_positions {
my ( $data, $spec ) = @_;
if ( !$spec ) {
if ( !defined($data) ) {
return;
} elsif ( !$spec ) {
return $data;
} elsif ( $spec =~ /p(\d+)$/ ) {
my $pos = $1;