diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm index c0598b1292..6095f51eda 100644 --- a/Koha/Plugins.pm +++ b/Koha/Plugins.pm @@ -27,7 +27,9 @@ use C4::Context; use C4::Output; BEGIN { - push @INC, C4::Context->config("pluginsdir"); + my $pluginsdir = C4::Context->config("pluginsdir"); + my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir; + push( @INC, @pluginsdir ); pop @INC if $INC[-1] eq '.'; } diff --git a/Koha/Plugins/Handler.pm b/Koha/Plugins/Handler.pm index 0c0a7b476b..e613b866c4 100644 --- a/Koha/Plugins/Handler.pm +++ b/Koha/Plugins/Handler.pm @@ -26,8 +26,10 @@ use Module::Load::Conditional qw(can_load); use C4::Context; BEGIN { - push @INC, C4::Context->config("pluginsdir"); - pop @INC if $INC[-1] eq '.' ; + my $pluginsdir = C4::Context->config("pluginsdir"); + my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir; + push( @INC, @pluginsdir ); + pop @INC if $INC[-1] eq '.' ; } =head1 NAME @@ -83,8 +85,14 @@ sub delete { return unless ( C4::Context->config("enable_plugins") || $args->{'enable_plugins'} ); my $plugin_class = $args->{'class'}; - my $plugin_dir = C4::Context->config("pluginsdir"); - my $plugin_path = "$plugin_dir/" . join( '/', split( '::', $args->{'class'} ) ); + + my $plugin_path = $plugin_class; + $plugin_path =~ s/::/\//g; # Take class name, transform :: to / to get path + $plugin_path =~ s/$/.pm/; # Add .pm to the end + require $plugin_path; # Require the plugin to have it's path listed in INC + $plugin_path = + $INC{$plugin_path}; # Get the full true path to the plugin from INC + $plugin_path =~ s/.pm//; # Remove the .pm from the end Koha::Plugins::Handler->run({ class => $plugin_class, diff --git a/plugins/plugins-upload.pl b/plugins/plugins-upload.pl index 853b2acea4..1e315f9d0d 100755 --- a/plugins/plugins-upload.pl +++ b/plugins/plugins-upload.pl @@ -56,6 +56,7 @@ my %errors; if ($plugins_enabled) { if ( ( $op eq 'Upload' ) && $uploadfile ) { my $plugins_dir = C4::Context->config("pluginsdir"); + $plugins_dir = ref($plugins_dir) eq 'ARRAY' ? $plugins_dir->[0] : $plugins_dir; my $dirname = File::Temp::tempdir( CLEANUP => 1 ); $debug and warn "dirname = $dirname";