Bugzilla – Attachment 59537 Details for
Bug 17982
Fix the use of uniq in sub themelanguage
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17982: Fix the use of uniq in sub themelanguage
Bug-17982-Fix-the-use-of-uniq-in-sub-themelanguage.patch (text/plain), 3.02 KB, created by
Marcel de Rooy
on 2017-01-25 08:24:56 UTC
(
hide
)
Description:
Bug 17982: Fix the use of uniq in sub themelanguage
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-01-25 08:24:56 UTC
Size:
3.02 KB
patch
obsolete
>From 3f9f5b3213ae96d4cffd1c6b5557184df944921b Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 24 Jan 2017 16:39:28 +0100 >Subject: [PATCH] Bug 17982: Fix the use of uniq in sub themelanguage >Content-Type: text/plain; charset=utf-8 > >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. > >Added a unit test to be somewhat overcomplete :) > >Test plan: >[1] Run t/db_dependent/Templates.t >[2] Open a page on OPAC or intranet. (Did you restart Plack?) > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Templates.pm | 6 +++--- > t/db_dependent/Templates.t | 17 ++++++++++++++--- > 2 files changed, 17 insertions(+), 6 deletions(-) > >diff --git a/C4/Templates.pm b/C4/Templates.pm >index eebff11..10d0283 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) ] ); > } > } > >diff --git a/t/db_dependent/Templates.t b/t/db_dependent/Templates.t >index 236bd1e..aa841bd 100755 >--- a/t/db_dependent/Templates.t >+++ b/t/db_dependent/Templates.t >@@ -19,8 +19,10 @@ use Modern::Perl; > > use CGI; > >-use Test::More tests => 5; >+use Test::More tests => 7; >+use List::MoreUtils qw/uniq/; > use Test::Deep; >+use Test::MockModule; > > BEGIN { > use_ok( 'C4::Templates' ); >@@ -45,5 +47,14 @@ is( scalar @keys, 6, "GetColumnDefs correctly returns the 5 tables defined in co > my @tables = ( 'biblio', 'biblioitems', 'borrowers', 'items', 'statistics', 'subscription'); > cmp_deeply( \@keys, \@tables, "GetColumnDefs returns the expected tables"); > >- >-1; >+# simple test for themelanguage >+my $mod = Test::MockModule->new( 'C4::Languages' ); >+$mod->mock( 'getlanguage', sub { 'en' } ); >+my @retval = C4::Templates::themelanguage( C4::Context->config('intrahtdocs'), >+ 'about.tt', 'intranet', 'fake_query', >+); >+my $themeref = $retval[2]; >+is( @$themeref > 0, 1, 'We still assume to get back at least one theme' ); >+cmp_deeply( $themeref, [ uniq(@$themeref) ], 'Should be unique themes' ); >+ >+# End of tests >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17982
:
59511
|
59537
|
59630
|
59747
|
59748
|
59749
|
59750
|
59765
|
59766
|
59790
|
59791