Bug 35603

Summary: Add plugin feature to allow plugins to warn if any external library modules needed are missing
Product: Koha Reporter: Kyle M Hall (khall) <kyle>
Component: Plugin architectureAssignee: Kyle M Hall (khall) <kyle>
Status: Failed QA --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: kyle, magnus, martin.renvoize, nick, pedro.amorim, tomascohen
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:
Circulation function:
Attachments: Bug 35603: Add plugin feature to allow plugins to warn if any external library modules needed are missing
Bug 35603: Add plugin feature to allow plugins to warn if any external library modules needed are missing
Bug 35603: (follow-up) Fix colspan count
Bug 35603: Add plugin feature to allow plugins to warn if any external library modules needed are missing

Description Kyle M Hall (khall) 2023-12-19 14:25:34 UTC
Some plugins require extra modules not included with Koha, but there is no simple way to let a user know when installing a plugin.
Comment 1 Kyle M Hall (khall) 2023-12-19 14:31:02 UTC
Created attachment 160008 [details] [review]
Bug 35603: Add plugin feature to allow plugins to warn if any external library modules needed are missing

Some plugins require extra modules not included with Koha, but there is no simple way to let a user know when installing a plugin.

This patch allows a new metadata to be added that is a list of hashes
with the key module. The hash is used for future expansion to allow new
critera to be added such as minimum and maximum module version.

Test Plan:
1) Install any plugin
2) In the plugin metadata, add the following key:
libs => [ { module => 'Business::Barcode::EAN13' } ],
3) Apply this patch
4) Restart all the things!
5) Browse to plugins-home.pl, note the error listing the missing module
6) Install Business::Barcode::EAN13 from cpan
7) Reload the page
8) Note the error is gone!
Comment 2 Martin Renvoize (ashimema) 2023-12-19 16:30:25 UTC
Created attachment 160036 [details] [review]
Bug 35603: Add plugin feature to allow plugins to warn if any external library modules needed are missing

Some plugins require extra modules not included with Koha, but there is no simple way to let a user know when installing a plugin.

This patch allows a new metadata to be added that is a list of hashes
with the key module. The hash is used for future expansion to allow new
critera to be added such as minimum and maximum module version.

Test Plan:
1) Install any plugin
2) In the plugin metadata, add the following key:
libs => [ { module => 'Business::Barcode::EAN13' } ],
3) Apply this patch
4) Restart all the things!
5) Browse to plugins-home.pl, note the error listing the missing module
6) Install Business::Barcode::EAN13 from cpan
7) Reload the page
8) Note the error is gone!

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 3 Martin Renvoize (ashimema) 2023-12-19 16:30:27 UTC
Created attachment 160037 [details] [review]
Bug 35603: (follow-up) Fix colspan count

This isn't directly related to the bug, but was apparent whilst testing.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize (ashimema) 2023-12-19 16:33:48 UTC
Testing using my in-development crontab plugin with a 'conditional_load' branch: https://github.com/PTFS-Europe/koha-plugin-crontab/tree/conditional_load

I'm catching the missing module during the install method and returning false there. This allows plugin_methods to be properly set and the plugin files to remain on the system whilst preventing the __INSTALLED__ flag being set.

This means that whilst the plugin seen by Koha, it's marked with an error and displays the missing module information.. once the module is installed, the install sub runs to completion and the plugin works as expected :)
Comment 5 Kyle M Hall (khall) 2024-05-01 13:51:05 UTC
Created attachment 165975 [details] [review]
Bug 35603: Add plugin feature to allow plugins to warn if any external library modules needed are missing

Some plugins require extra modules not included with Koha, but there is no simple way to let a user know when installing a plugin.

This patch allows a new metadata to be added that is a list of hashes
with the key module. The hash is used for future expansion to allow new
critera to be added such as minimum and maximum module version.

Test Plan:
1) Install any plugin
2) In the plugin metadata, add the following key:
libs => [ { module => 'Business::Barcode::EAN13' } ],
3) Apply this patch
4) Restart all the things!
5) Browse to plugins-home.pl, note the error listing the missing module
6) Install Business::Barcode::EAN13 from cpan
7) Reload the page
8) Note the error is gone!

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Nick Clemens (kidclamp) 2024-09-27 20:57:55 UTC
This needs a rebase, it breaks the table when the error is present