From d928038a523b7ef44257ddfe97c405173c9b3b2e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 28 Aug 2017 14:00:28 -0300 Subject: [PATCH] Bug 19081: Do not list plugins that have been uninstalled Under plack, can_load should not check if a package is in cache, but reload it. Otherwise plugins that have been uninstalled will still get listed. The error raised by can_load must only be displayed if the plugin has been removed. Test plan: 1/ Upload a plugin 2/ Note the plugin is listed as installed 3/ Modify the package of the plugin to add a compilation error (use 'Foo' for instance) 4/ Reload the page 5/ The plugin is not listed and a warning appear in the logs 6/ Remove the compilation error and uninstall the plugin 7/ The plugin is no longer listed and no warning appear in the logs Signed-off-by: Lee Jamison Signed-off-by: Kyle M Hall Bug 19081: Remove useless $plugin_file variable Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart --- Koha/Plugins.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm index ef1ab2559c..c0aaa9cb37 100644 --- a/Koha/Plugins.pm +++ b/Koha/Plugins.pm @@ -74,7 +74,7 @@ sub GetPlugins { my @plugins; foreach my $plugin_class (@plugin_classes) { - if ( can_load( modules => { $plugin_class => undef } ) ) { + if ( can_load( modules => { $plugin_class => undef }, nocache => 1 ) ) { next unless $plugin_class->isa('Koha::Plugins::Base'); my $plugin = $plugin_class->new({ enable_plugins => $self->{'enable_plugins'} }); @@ -87,7 +87,9 @@ sub GetPlugins { and any { !$plugin_metadata->{$_} || $plugin_metadata->{$_} ne $req_metadata->{$_} } keys %$req_metadata; push @plugins, $plugin; } else { - warn $Module::Load::Conditional::ERROR; + my $error = $Module::Load::Conditional::ERROR; + # Do not warn the error if the plugin has been uninstalled + warn $error unless $error =~ m|^Could not find or check module '$plugin_class'|; } } return @plugins; -- 2.39.5