From 8b7101ab4d1e67d5ca753d36081e4646587bfc08 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 Signed-off-by: Martin Renvoize --- 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 1b4a9bf82bb..88ea0649c98 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 0ff204281d6..b0c084a6c5e 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.51.1