diff --git a/C4/Context.pm b/C4/Context.pm index 2cd62adc3e..6c51b3b862 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -22,19 +22,6 @@ use Modern::Perl; use vars qw($AUTOLOAD $context); BEGIN { - # Load plugins early to ensure they're available before any transactions begin - my $enable_plugins = 0; - if ( exists $ENV{'KOHA_CONF'} && -e $ENV{'KOHA_CONF'} ) { - require Koha::Config; - my $config = Koha::Config->get_instance; - $enable_plugins = $config->get('enable_plugins') // 0; - } - - if ($enable_plugins) { - require Koha::Plugins::Loader; - Koha::Plugins::Loader->get_enabled_plugins(); - } - if ( $ENV{'HTTP_USER_AGENT'} ) { # Only hit when plack is not enabled # Redefine multi_param if cgi version is < 4.08 diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm index 84ca675c5f..4d0cc82876 100644 --- a/Koha/Plugins.pm +++ b/Koha/Plugins.pm @@ -45,6 +45,15 @@ BEGIN { my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir; push @INC, array_minus( @pluginsdir, @INC ); pop @INC if $INC[-1] eq '.'; + + # Load plugins early to ensure they're available before any transactions begin + my $enable_plugins = C4::Context->config("enable_plugins") // 0; + + if ($enable_plugins) { + require Koha::Plugins::Loader; + Koha::Plugins::Loader->get_enabled_plugins(); + } + } =head1 NAME