From 9c40765734da41f1e1c18cb5fd4fabd17452bac5 Mon Sep 17 00:00:00 2001 From: Michael Hafen Date: Fri, 7 May 2021 14:13:49 -0600 Subject: [PATCH] Bug 28303: Fix plugins system with multiple pluginsdir settings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit C4/Templates::badtemplatecheck mucks with the config('pluginsdir') array ref. This makes sure it operates on a copy of the array. To test: 1) $ prove t/db_dependent/Templates.t Signed-off-by: David Nind JK: Fix commit message styling and add test plan Signed-off-by: Joonas Kylmälä Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit 9b9ac630ed4858d8a2f9c7a0f9e5ac02b9359a17) Signed-off-by: Fridolin Somers --- C4/Templates.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/C4/Templates.pm b/C4/Templates.pm index bad3275959..aa2ea71006 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -187,9 +187,14 @@ sub badtemplatecheck { # This also includes two dots Koha::Exceptions::NoPermission->throw( 'bad template path' ); } else { - # Check allowed dirs + # Check allowed dirs - make sure we operate on a copy of the config my $dirs = C4::Context->config("pluginsdir"); - $dirs = [ $dirs ] if !ref($dirs); + if ( !ref($dirs) ) { + $dirs = [ $dirs ]; + } + else { + $dirs = [ @$dirs ]; + } unshift @$dirs, C4::Context->config('opachtdocs'), C4::Context->config('intrahtdocs'); my $found = 0; foreach my $dir ( @$dirs ) { -- 2.39.5