From 2db796712b59e29380d25d83506e43bcbf07013c Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Wed, 19 Oct 2022 15:59:22 +0200 Subject: [PATCH] Bug 31856: Don't fetch additional field valudes if there are no fields --- C4/Serials.pm | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index ed2986865d1..0ac8802d3ac 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -623,16 +623,22 @@ sub SearchSubscriptions { for my $subscription ( @$results ) { $subscription->{cannotedit} = not can_edit_subscription( $subscription ); $subscription->{cannotdisplay} = not can_show_subscription( $subscription ); - my @additional_field_values = Koha::AdditionalFieldValues->search( - { - field_id => { -in => [ keys %additional_fields_by_id ] }, - record_id => $subscription->{subscriptionid} - } - )->as_list; - $subscription->{additional_fields} = { - map { $additional_fields_by_id{$_->field_id} => $_->value } @additional_field_values - }; + if (%additional_fields_by_id) { + my @additional_field_values = Koha::AdditionalFieldValues->search( + { + field_id => { -in => [ keys %additional_fields_by_id ] }, + record_id => $subscription->{subscriptionid} + } + )->as_list; + + $subscription->{additional_fields} = { + map { $additional_fields_by_id{$_->field_id} => $_->value } @additional_field_values + }; + } + else { + $subscription->{additional_fields} = {}; + } } return @$results; -- 2.25.1