Bug 24031: Add safety checks in Koha::Plugins::call
- Check that the plugin has the method before calling it - Call the method in an eval block to prevent fatal errors Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
e5e058e39f
commit
9319c8879f
1 changed files with 7 additions and 1 deletions
|
@ -66,8 +66,14 @@ sub call {
|
||||||
if (C4::Context->config('enable_plugins')) {
|
if (C4::Context->config('enable_plugins')) {
|
||||||
my @plugins = $class->new({ enable_plugins => 1 })->GetPlugins({ method => $method });
|
my @plugins = $class->new({ enable_plugins => 1 })->GetPlugins({ method => $method });
|
||||||
my @responses;
|
my @responses;
|
||||||
|
@plugins = grep { $_->can($method) } @plugins;
|
||||||
foreach my $plugin (@plugins) {
|
foreach my $plugin (@plugins) {
|
||||||
my $response = $plugin->$method(@args);
|
my $response = eval { $plugin->$method(@args) };
|
||||||
|
if ($@) {
|
||||||
|
warn sprintf("Plugin error (%s): %s", $plugin->get_metadata->{name}, $@);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
push @responses, $response;
|
push @responses, $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue