From 5c1daf010ec97ed405bf7825eaa8143c225252b1 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 24 Jan 2017 16:39:28 +0100 Subject: [PATCH] Bug 17982: Fix the use of uniq in sub themelanguage Doing uniq( \@themes ) is useless. It will just return to you the only reference you gave it. List::MoreUtils::uniq requires a list instead of an arrayref. So it is a trivial fix that makes sub themelanguage return one theme instead of three themes like [ 'prog', 'prog', 'prog' ]. Note that Template->new inserts one or two include paths to TT for each of these three identical themes. Test plan: [1] Run t/db_dependent/Templates.t (should no longer fail) [2] Run t/db_dependent/Auth.t (triggering themelanguage) [3] Open a page on OPAC or intranet. (Did you restart Plack?) Signed-off-by: Marcel de Rooy Signed-off-by: Mark Tompsett EDIT (Marcel): Amended test plan for additional unit test. Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- C4/Templates.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/C4/Templates.pm b/C4/Templates.pm index eebff1102d..10d028334a 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -256,18 +256,18 @@ sub themelanguage { my $where = $tmpl =~ /xsl$/ ? 'xslt' : 'modules'; for my $theme (@themes) { if ( -e "$htdocs/$theme/$lang/$where/$tmpl" ) { - return ( $theme, $lang, uniq( \@themes ) ); + return ( $theme, $lang, [ uniq(@themes) ] ); } } # Otherwise return theme/'en', last resort fallback/'en' for my $theme (@themes) { if ( -e "$htdocs/$theme/en/$where/$tmpl" ) { - return ( $theme, 'en', uniq( \@themes ) ); + return ( $theme, 'en', [ uniq(@themes) ] ); } } # tmpl is a full path, so this is a template for a plugin if ( $tmpl =~ /^\// && -e $tmpl ) { - return ( $themes[0], $lang, uniq( \@themes ) ); + return ( $themes[0], $lang, [ uniq(@themes) ] ); } } -- 2.39.5