From 91171650ac980415d9d2976fa6b19365fe545b37 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 7 Apr 2017 12:51:49 -0400 Subject: [PATCH] Bug 18400 - Noisy warns in opac-search.pl during itemtype sorting MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit To fix the warns we use a copy of itemtypes which is not touched by other code To test: Apply patches Ensure search still works Followed test plan, search works as expected. Signed-off-by: Marc Véron Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- opac/opac-search.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opac/opac-search.pl b/opac/opac-search.pl index a6d205ad6b..3d034abef6 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -229,6 +229,8 @@ foreach my $itemtype ( keys %{$itemtypes} ) { $itemtypes->{$itemtype}->{translated_description} = ( $translated_description ) ? $translated_description : $itemtypes->{$itemtype}->{description}; } +my $itemtypes_copy = { %$itemtypes }; #Sometime itemtypes can be corrupted in advanced_srch_type loop + #Making a copy ensure it is clean # the index parameter is different for item-level itemtypes my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'itemtype'; my @advancedsearchesloop; @@ -254,7 +256,8 @@ foreach my $advanced_srch_type (@advanced_search_types) { if ($advanced_srch_type eq 'itemtypes') { # itemtype is a special case, since it's not defined in authorized values my @itypesloop; - foreach my $thisitemtype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description} } keys %$itemtypes ) { + my @sorted_itemtypes = ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description} } keys %$itemtypes_copy ); + foreach my $thisitemtype ( @sorted_itemtypes ) { next if $hidingrules->{itype} && any { $_ eq $thisitemtype } @{$hidingrules->{itype}}; next if $hidingrules->{itemtype} && any { $_ eq $thisitemtype } @{$hidingrules->{itemtype}}; my %row =( number=>$cnt++, -- 2.39.5