Bug 38384: (follow-up) Move loading into Koha::Plugins BEGIN block

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 <tomascohen@theke.io>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2026-01-22 13:51:46 +00:00 committed by Lucas Gass
parent e091b0d4bc
commit 84e0caae64
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 9 additions and 13 deletions

View File

@ -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

View File

@ -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