From a1335333a6fb3b5b979a6f2b4141c8a852446eb7 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Fri, 11 Sep 2020 16:03:28 +0200 Subject: [PATCH] Bug 26434: Fix plugin dirs addition to @INC Plugin dirs defined in koha-conf.xml are added to @INC in order to compile perl code. Looks like with plack those dirs are added several times. This may lead to an error "INCLUDE_PATH exceeds 64 directories". This bug was identified with Carrousel plugin : https://inlibro.com/instructions-carrousel/ Test plan : 1) Enable plack and plugins 2) Look at page about.pl : @INC contains one plugin dir 'var/lib/plugins' 3) Install plugin KitchenSink : https://github.com/bywatersolutions/koha-plugin-kitchen-sink 4) Dont apply patch 5) Use configure on KitchenSink 6) Look at page about.pl : @INC contains server plugin dir 'var/lib/plugins' 7) Apply patch and restart plack 8) Use configure on KitchenSink 9) Look at page about.pl : @INC contains one plugin dir 'var/lib/plugins' Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart (cherry picked from commit dcdc72aee7d835c08ca3565a83a3dae7389a4f87) Signed-off-by: Lucas Gass (cherry picked from commit aaef04500654a997f722c17adff017a0a4687e8d) Signed-off-by: Aleisha Amohia (cherry picked from commit 97a15fe1869dbdefcdb10f812a5adcb36becc7a7) Signed-off-by: Victor Grousset/tuxayo --- Koha/Plugins.pm | 3 ++- Koha/Plugins/Handler.pm | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm index be6bf3304d..000555dbfd 100644 --- a/Koha/Plugins.pm +++ b/Koha/Plugins.pm @@ -19,6 +19,7 @@ package Koha::Plugins; use Modern::Perl; +use Array::Utils qw(array_minus); use Module::Load::Conditional qw(can_load); use Module::Pluggable search_path => ['Koha::Plugin'], except => qr/::Edifact(|::Line|::Message|::Order|::Segment|::Transport)$/; use List::MoreUtils qw( any ); @@ -29,7 +30,7 @@ use C4::Output; BEGIN { my $pluginsdir = C4::Context->config("pluginsdir"); my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir; - push( @INC, @pluginsdir ); + push @INC, array_minus(@pluginsdir, @INC) ; pop @INC if $INC[-1] eq '.'; } diff --git a/Koha/Plugins/Handler.pm b/Koha/Plugins/Handler.pm index 5b6e3e3787..32649e5fac 100644 --- a/Koha/Plugins/Handler.pm +++ b/Koha/Plugins/Handler.pm @@ -19,6 +19,7 @@ package Koha::Plugins::Handler; use Modern::Perl; +use Array::Utils qw(array_minus); use File::Path qw(remove_tree); use Module::Load::Conditional qw(can_load); @@ -28,7 +29,7 @@ use C4::Context; BEGIN { my $pluginsdir = C4::Context->config("pluginsdir"); my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir; - push( @INC, @pluginsdir ); + push @INC, array_minus(@pluginsdir, @INC) ; pop @INC if $INC[-1] eq '.' ; } -- 2.39.5