Bug 39522: (follow up) Add defensive checking before instantiating plugins object

Previously this could have caused issues if enable_plugins was disabled
in koha-conf as we were not checking enabled status before instantiating
an instance of the plugins object.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 05423a313b)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Jacob O'Mara 2025-11-13 10:12:06 +00:00 committed by Jacob O'Mara
parent fe7d8e922a
commit e4e2fcd64f
No known key found for this signature in database
1 changed files with 6 additions and 2 deletions

View File

@ -213,8 +213,12 @@ sub _error {
sub _load {
my ($self) = @_;
# Try to find the class that can handle this plugin
my @plugins = Koha::Plugins->new()->get_valuebuilders_installed();
# Try to find the class that can handle this plugin, but only if plugins are enabled
my @plugins;
if ( C4::Context->config("enable_plugins") ) {
my $plugins_obj = Koha::Plugins->new();
@plugins = $plugins_obj->get_valuebuilders_installed() if $plugins_obj;
}
foreach my $vb (@plugins) {
my $plugin = $vb->{plugin};