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 <pedro.amorim@ptfs-europe.com>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 7e336006c2)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2024-10-29 11:12:04 +00:00 committed by Lucas Gass
parent 4dfd705f9d
commit fde180efbf
2 changed files with 12 additions and 7 deletions

View File

@ -401,20 +401,23 @@ sub status {
my $backend_plugin = $self->get_backend_plugin($backend_name);
Returns the installed I<Koha::Plugin> corresponding to the given backend_id
Returns the installed I<Koha::Plugin> 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];
}

View File

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