From 5ca37be9b5e4e949e0ff4dc9b54c391df6377af6 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 2 Jun 2025 11:00:31 +0200 Subject: [PATCH] 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 Signed-off-by: David Nind --- C4/Breeding.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/C4/Breeding.pm b/C4/Breeding.pm index cb6811b0e3..e6c56b99b0 100644 --- a/C4/Breeding.pm +++ b/C4/Breeding.pm @@ -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; -- 2.39.5