Bug 41706: "Use of uninitialized value..." warning in C4/Record.pm

The warning:
[WARN] Use of uninitialized value $2 in split
    at /kohadevbox/koha/C4/Record.pm line 924.
appears in the plack-opac-error.log file.
It happens during the preparation of data for the "Cite" feature
in OPAC for some of author's fields.

To test:
========
1. Observe plack-opac-error.log.
2. In OPAC go to record with one word author like Aristophanes,
   Aristotle or Xenophon (biblionumbers: 64, 176, 254).
3. Show it in any of "detail" view (Normal, MARC, ISBD).
4. Warning appears in plack-opac-error.log.
5. Apply the patch; restart_all.
6. Repeat 2-3. Warning doesn't appear.

Sponsored-by: Ignatianum University in Cracow
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Roman Dolny 2026-01-25 13:40:10 +00:00 committed by Pedro Amorim
parent 138d2b64ed
commit b60b7c3a3f
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 4 additions and 2 deletions

View File

@ -919,9 +919,11 @@ sub marc2cites {
$author = $field->subfield("a");
}
if ( $author =~ /([^,]+),?(.*)/ ) {
my $surname = $1;
my $forenames = $2;
my %a;
( $a{'surname'} = $1 ) =~ s/$re_clean//g;
$a{'forenames'} = [ map { my $t = $_; $t =~ s/$re_clean//g; $t } split ' ', $2 ];
( $a{'surname'} = $surname ) =~ s/$re_clean//g;
$a{'forenames'} = [ map { my $t = $_; $t =~ s/$re_clean//g; $t } split ' ', $forenames ];
push( @authors, \%a );
}
}