Bug 32539 - UI hooks can break the UI
Summary: UI hooks can break the UI
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Plugin architecture (show other bugs)
Version: Main
Hardware: All All
: P5 - low major (vote)
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-28 15:32 UTC by Katrin Fischer
Modified: 2023-12-28 20:44 UTC (History)
5 users (show)

See Also:
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 (2.76 KB, patch)
2023-01-16 04:43 UTC, David Cook
Details | Diff | Splinter Review
Koha plugin to use for testing this patch (1.33 KB, application/zip)
2023-01-16 04:50 UTC, David Cook
Details
Bug 32539: Add exception handling to plugin hooks in template plugin (2.81 KB, patch)
2023-01-17 18:46 UTC, David Nind
Details | Diff | Splinter Review
Bug 32539: Add exception handling to plugin hooks in template plugin (2.88 KB, patch)
2023-02-09 10:45 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 32539: Add tests (2.42 KB, patch)
2023-02-09 10:45 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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