From e3fd4a13e64fa9e2453a38b0074cfebec43ba954 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 22 Jan 2026 13:51:46 +0000 Subject: [PATCH] Bug 38384: (follow-up) Move loading into Koha::Plugins BEGIN block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thinking about this today, we really just need the plugins initialized anytime we are using Koha::Plugins Moving the loading into the BEGIN there seems to resolve the issue Signed-off-by: Tomás Cohen Arazi --- C4/Context.pm | 13 ------------- Koha/Plugins.pm | 9 +++++++++ 2 files changed, 9 insertions(+), 13 deletions(-) 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 -- 2.50.1 (Apple Git-155)