From fa3716d1fba4b1cdc3a3ce0984a3d0ee19eebc46 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 13 Jun 2022 14:26:33 +0100 Subject: [PATCH] Bug 30848: Fix issue exposed by unit tests This patch changes the 'map' to a simple for loop so that we can easily map multiple subfields to a field without overwriting the first previous subfields in the structure. --- Koha/Filter/MARC/ExpandCodedFields.pm | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Koha/Filter/MARC/ExpandCodedFields.pm b/Koha/Filter/MARC/ExpandCodedFields.pm index 79b056431f..909d908e01 100644 --- a/Koha/Filter/MARC/ExpandCodedFields.pm +++ b/Koha/Filter/MARC/ExpandCodedFields.pm @@ -114,14 +114,8 @@ sub _getCodedFields { my $cached = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); return $cached if $cached; - my $coded_fields = { - map { - $_->tagfield => { - $_->tagsubfield => { - 'authorised_value' => $_->authorised_value - } - } - } Koha::MarcSubfieldStructures->search( + my $coded_fields = {}; + my @fields = Koha::MarcSubfieldStructures->search( { frameworkcode => $frameworkcode, authorised_value => { '>' => '' } @@ -130,8 +124,10 @@ sub _getCodedFields { columns => [ 'tagfield', 'tagsubfield', 'authorised_value' ], order_by => [ 'tagfield', 'tagsubfield' ] } - )->as_list - }; + )->as_list; + for my $field (@fields) { + $coded_fields->{ $field->tagfield }->{ $field->tagsubfield }->{'authorised_value'} = $field->authorised_value; + } $cache->set_in_cache( $cache_key, $coded_fields ); return $coded_fields; -- 2.20.1