From 94ea476cf68c75767ffd39efb7aa4a285308bd6b Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 17 Aug 2020 00:31:34 +0000 Subject: [PATCH] Bug 25384: Use dclone when copying font lookup hash This patch includes the logic from Bug 25852. That is, use dclone to copy the hash used as the font lookup. While the original patch perfectly copied the top level keys, the next level down were hash references (due to Perl's inherent hash design), and changes to the 2nd level of depth would be changes to these references which would impact the original hash. --- C4/Creators/Lib.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/C4/Creators/Lib.pm b/C4/Creators/Lib.pm index 068e5e7df3..9955b55d0d 100644 --- a/C4/Creators/Lib.pm +++ b/C4/Creators/Lib.pm @@ -445,14 +445,14 @@ This function returns a reference to an array of hashes containing all font type sub get_font_types { my @available_fonts = (); - my %available_font_lookup = %default_font_types; + my $available_font_lookup = dclone(\%default_font_types); #Add new fonts or rename default fonts my $ttf = C4::Context->config('ttf'); if ($ttf && $ttf->{font} && ref $ttf->{font} eq 'ARRAY'){ foreach my $font ( @{$ttf->{font}} ){ if ($font->{type} && $font->{name} && $font->{content}){ - $available_font_lookup{ $font->{type} } = { name => $font->{name}, }; + $available_font_lookup->{ $font->{type} } = { name => $font->{name}, }; } } } @@ -460,15 +460,15 @@ sub get_font_types { #Output default font types first (in default order) _use_font({ font_types => \@default_font_type_codes, - font_lookup => \%available_font_lookup, + font_lookup => $available_font_lookup, available_fonts => \@available_fonts, }); #Output configured font types last (in alphabetical order) - my @remaining_types = sort keys %available_font_lookup; + my @remaining_types = sort keys %$available_font_lookup; _use_font({ font_types => \@remaining_types, - font_lookup => \%available_font_lookup, + font_lookup => $available_font_lookup, available_fonts => \@available_fonts, }); -- 2.11.0