From b971653992401feaea0ea26a1ab0aad0235d1844 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 7 Nov 2024 06:53:39 -0500 Subject: [PATCH] Bug 38384: Trigger plugin modules loading as soon as possible in Koha MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomás Cohen Arazi Signed-off-by: Andrew Fuerste Henry Signed-off-by: Marcel de Rooy --- C4/Context.pm | 7 ++++++- Koha/BackgroundJob.pm | 6 ------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index 6c51b3b862..6481c1f437 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -22,7 +22,12 @@ use Modern::Perl; use vars qw($AUTOLOAD $context); BEGIN { - if ( $ENV{'HTTP_USER_AGENT'} ) { # Only hit when plack is not enabled + # Calling get_enabled_plugins here esnures that all plugin + # modules are loaded before use and will not trigger + # a database connection reset + Koha::Plugins->get_enabled_plugins(); + + if ( $ENV{'HTTP_USER_AGENT'} ) { # Only hit when plack is not enabled # Redefine multi_param if cgi version is < 4.08 # Remove the "CGI::param called in list context" warning in this case diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index 0ff204281d..b0c084a6c5 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -189,12 +189,6 @@ sub process { return {} if ref($self) ne 'Koha::BackgroundJob'; - # Our background jobs are called in forked processes - # to ensure we have all plugin hooks and data we call - # get_enabled_plugins at the star of processing - # to populate the cache - Koha::Plugins->get_enabled_plugins(); - my $derived_class = $self->_derived_class; $args ||= {}; -- 2.39.5