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>
This commit is contained in:
Jonathan Druart 2022-10-17 16:00:25 +02:00 committed by Tomas Cohen Arazi
parent edf8640cff
commit b582f7d495
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 3 additions and 2 deletions

View File

@ -152,7 +152,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 ) )
@ -162,7 +163,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, ' ' );