From 6af6a5f1382622653c1e3a379119b2a4a9638000 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 29 Oct 2024 11:12:04 +0000 Subject: [PATCH] Bug 37872: Consider enable_plugins = 0 when fetching plugin backends This patch builds on top of Andreas patch checking for Koha::Plugins->new() instead as the enable_plugins is already done there. It also adds a check in reply to Joubu's observation, which is indeed an additional bug. Test plan: 1) Apply tests patch. Run the tests. Notice it fails 2) Apply the remaining patches. Run the tests. Notice they pass. Additional (and better) tests can be written, but for now I think this is good enough. Additional tests should be written on top of bug 36197 (which adds a dummy ILL backend plugin for testing), at: https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=36197&attachment=171371 Signed-off-by: Pedro Amorim --- Koha/ILL/Request.pm | 9 ++++++--- Koha/ILL/Request/Config.pm | 10 ++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index 9bc3ebc4d2..8923db9e86 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -403,20 +403,23 @@ sub status { my $backend_plugin = $self->get_backend_plugin($backend_name); -Returns the installed I corresponding to the given backend_id +Returns the installed I corresponding to the given backend_id or undef if no plugin is found =cut sub get_backend_plugin { my ( $self, $backend_id ) = @_; - my @backend_plugins = Koha::Plugins->new()->GetPlugins( + my $koha_plugins = Koha::Plugins->new(); + my @backend_plugins = $koha_plugins + ? Koha::Plugins->new()->GetPlugins( { method => 'ill_backend', metadata => { name => $backend_id }, all => 1, } - ); + ) + : (); return $backend_plugins[0]; } diff --git a/Koha/ILL/Request/Config.pm b/Koha/ILL/Request/Config.pm index 332bc7cbb2..687c343cc6 100644 --- a/Koha/ILL/Request/Config.pm +++ b/Koha/ILL/Request/Config.pm @@ -113,15 +113,17 @@ Returns a list of names for all the installed ILL backend plugins. =cut sub get_backend_plugin_names { - my ( $self ) = @_; + my ($self) = @_; - return () unless C4::Context->config("enable_plugins"); - my @backend_plugins = Koha::Plugins->new()->GetPlugins( + my $koha_plugins = Koha::Plugins->new(); + my @backend_plugins = $koha_plugins + ? $koha_plugins->GetPlugins( { method => 'ill_backend', all => 1 } - ); + ) + : (); return map { $_->{metadata}->{name} } @backend_plugins; } -- 2.39.5