Bug 28303: Fix plugins system with multiple pluginsdir settings
authorMichael Hafen <michael.hafen@washk12.org>
Fri, 7 May 2021 20:13:49 +0000 (14:13 -0600)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 5 Oct 2021 08:58:13 +0000 (10:58 +0200)
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 <david@davidnind.com>
JK: Fix commit message styling and add test plan

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
C4/Templates.pm

index f6fefaa..d41c9b5 100644 (file)
@@ -186,9 +186,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 ) {