Bug 32539

Summary: UI hooks can break the UI
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: Plugin architectureAssignee: David Cook <dcook>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: arthur.suzuki, david, dcook, lucas, wainuiwitikapark
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.03,22.05.10,21.11.18
Attachments: Bug 32539: Add exception handling to plugin hooks in template plugin
Koha plugin to use for testing this patch
Bug 32539: Add exception handling to plugin hooks in template plugin
Bug 32539: Add exception handling to plugin hooks in template plugin
Bug 32539: Add tests

Description Katrin Fischer 2022-12-28 15:32:48 UTC
For example if there is an error in the opac_js hook, it will break the OPAC with an internal server error on all pages, not only the one the hook is used on.
Comment 1 David Cook 2023-01-16 04:43:30 UTC
Created attachment 145328 [details] [review]
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
Comment 2 David Cook 2023-01-16 04:50:54 UTC
Created attachment 145329 [details]
Koha plugin to use for testing this patch

Koha plugin to use for testing this patch
Comment 3 David Nind 2023-01-17 18:46:04 UTC
Created attachment 145366 [details] [review]
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>
Comment 4 David Nind 2023-01-17 18:47:09 UTC
Thanks David for providing a plugin to test this with!
Comment 5 Jonathan Druart 2023-02-09 10:45:43 UTC
Created attachment 146423 [details] [review]
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>
Comment 6 Jonathan Druart 2023-02-09 10:45:46 UTC
Created attachment 146424 [details] [review]
Bug 32539: Add tests

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 7 Tomás Cohen Arazi 2023-02-09 13:01:36 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 8 Jacob O'Mara 2023-02-13 09:46:11 UTC
Nice work, thanks everyone!

Pushed to 22.11.x for the next release.
Comment 9 Lucas Gass 2023-02-15 22:10:42 UTC
Backported to 22.05.x for upcoming 22.05.10
Comment 10 Arthur Suzuki 2023-02-17 13:10:33 UTC
applied to 21.11.x for 21.11.18
Comment 11 wainuiwitikapark 2023-03-15 02:21:26 UTC
Not backported to 21.05.x