Bug 39772: Display package names for plugin jobs rather than "unknown" messages

This slightly improves the current situation, where on background_jobs.pl
each plugin job would be displayed as "Unknown job type 'plugin_...'".
After this patch, we display the implementing package name
(sourced from plugins' background_tasks()), which is slightly more
human-friendly and significantly less error-looking.

Test plan:

1. In KTD, install a plugin implementing background jobs (e.g. the KitchenSink)
2. On http://localhost:8081/cgi-bin/koha/plugins/plugins-home.pl,
   enable the plugin and run a tool/report from it
3. Observe ugly job types column on http://localhost:8081/cgi-bin/koha/admin/background_jobs.pl
4. Apply the patch
5. Observe the improved job types on http://localhost:8081/cgi-bin/koha/admin/background_jobs.pl

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
This commit is contained in:
Tadeusz „tadzik” Sośnierz 2025-04-29 14:20:39 +02:00 committed by Jesse Maseto
parent 1192a706cb
commit a368406305
No known key found for this signature in database
GPG Key ID: 4D16BFCF78FFFDEC
2 changed files with 23 additions and 0 deletions

View File

@ -82,4 +82,21 @@ $template->param(
op => $op,
);
my @plugins = Koha::Plugins::GetPlugins(
{
method => 'background_tasks',
}
);
my @plugin_job_types;
for my $plugin (@plugins) {
my $tasks = $plugin->background_tasks;
for my $id ( keys %$tasks ) {
push @plugin_job_types, {
id => 'plugin_' . $plugin->get_metadata->{namespace} . "_$id",
str => $tasks->{$id},
};
}
}
$template->param( plugin_job_types => \@plugin_job_types );
output_html_with_http_headers $input, $cookie, $template->output;

View File

@ -243,6 +243,12 @@
'_id': 'import_from_kbart_file',
'_str': _("Import titles from a KBART file")
},
[% FOR job_type IN plugin_job_types %]
{
'_id': '[% job_type.id %]',
'_str': '[% job_type.str %]'
},
[% END %]
];
function get_job_type (job_type) {