Bug 32539: Add exception handling to plugin hooks in template plugin

This change wraps Koha plugin hook calls with exception handling
within the template plugin for Koha plugins.

Test plan:
0) Apply patch
1) Install a plugin that provides "opac_head", "opac_js",
"intranet_head", and "intranet_js" with Perl errors in them
2) Load an OPAC page
3) Note that the OPAC page loads correctly
4) Load a staff interace page
5) Note that the staff interface page loads correctly

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
David Cook 2023-01-16 04:41:01 +00:00 committed by Tomas Cohen Arazi
parent c6c2fe81a2
commit 23a0021122
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -61,7 +61,16 @@ sub get_plugins_opac_head {
}
);
my @data = map { $_->opac_head || q{} } @plugins;
my @data = ();
foreach my $plugin (@plugins){
try {
my $datum = $plugin->opac_head || q{};
push(@data,$datum);
}
catch {
warn "Error calling 'opac_head' on the " . $plugin->{class} . "plugin ($_)";
};
}
return join( "\n", @data );
}
@ -88,7 +97,16 @@ sub get_plugins_opac_js {
}
);
my @data = map { $_->opac_js || q{} } @plugins;
my @data = ();
foreach my $plugin (@plugins){
try {
my $datum = $plugin->opac_js || q{};
push(@data,$datum);
}
catch {
warn "Error calling 'opac_js' on the " . $plugin->{class} . "plugin ($_)";
};
}
return join( "\n", @data );
}
@ -115,7 +133,16 @@ sub get_plugins_intranet_head {
}
);
my @data = map { $_->intranet_head || q{} } @plugins;
my @data = ();
foreach my $plugin (@plugins){
try {
my $datum = $plugin->intranet_head || q{};
push(@data,$datum);
}
catch {
warn "Error calling 'intranet_head' on the " . $plugin->{class} . "plugin ($_)";
};
}
return join( "\n", @data );
}
@ -142,7 +169,16 @@ sub get_plugins_intranet_js {
}
);
my @data = map { $_->intranet_js || q{} } @plugins;
my @data = ();
foreach my $plugin (@plugins){
try {
my $datum = $plugin->intranet_js || q{};
push(@data,$datum);
}
catch {
warn "Error calling 'intranet_js' on the " . $plugin->{class} . "plugin ($_)";
};
}
return join( "\n", @data );
}