Bug 31154: Avoid unecessary loop

We don't need to loop over the subfield and enter this block if there is
no record.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit b582f7d495)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2022-10-17 16:00:25 +02:00 committed by Lucas Gass
parent 8735f0732c
commit 23d0af2eab
1 changed files with 3 additions and 2 deletions

View File

@ -151,7 +151,8 @@ sub generate_subfield_form {
&& !$value
&& $subfield->{kohafield}
&& $subfield->{kohafield} eq 'items.itemcallnumber'
&& $pref_itemcallnumber )
&& $pref_itemcallnumber
&& $marc_record )
{
foreach
my $pref_itemcallnumber_part ( split( /,/, $pref_itemcallnumber ) )
@ -161,7 +162,7 @@ sub generate_subfield_form {
my $CNsubfields =
substr( $pref_itemcallnumber_part, 3 ); # Any and all subfields
$CNsubfields = undef if $CNsubfields eq '';
my $temp2 = $marc_record ? $marc_record->field($CNtag) : undef;
my $temp2 = $marc_record->field($CNtag);
next unless $temp2;
$value = $temp2->as_string( $CNsubfields, ' ' );