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 <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Fridolin Somers 2020-09-11 16:03:28 +02:00 committed by Jonathan Druart
parent 647e05d826
commit dcdc72aee7
2 changed files with 4 additions and 2 deletions

View File

@ -19,6 +19,7 @@ package Koha::Plugins;
use Modern::Perl;
use Array::Utils qw(array_minus);
use Class::Inspector;
use List::MoreUtils qw(any);
use Module::Load::Conditional qw(can_load);
@ -32,7 +33,7 @@ use Koha::Plugins::Methods;
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 '.';
}

View File

@ -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 qw(load);
@ -29,7 +30,7 @@ use Koha::Plugins::Methods;
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 '.' ;
}