From ce924ac29781f6aa1610e54ea629f88551e07095 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 17 Oct 2022 16:00:25 +0200 Subject: [PATCH] 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 Signed-off-by: Tomas Cohen Arazi (cherry picked from commit b582f7d495fceda68a7972f7eab0d4e5d16bdcdf) Signed-off-by: Lucas Gass (cherry picked from commit 23d0af2eab453deabf76b805a16ef1e97c795f7e) Signed-off-by: Arthur Suzuki --- Koha/UI/Form/Builder/Item.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Koha/UI/Form/Builder/Item.pm b/Koha/UI/Form/Builder/Item.pm index 18b010fc76..504cc38625 100644 --- a/Koha/UI/Form/Builder/Item.pm +++ b/Koha/UI/Form/Builder/Item.pm @@ -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, ' ' ); -- 2.39.5