From a489a115521e5ce98489de3fb95ce0de52987abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadeusz=20=E2=80=9Etadzik=E2=80=9D=20So=C5=9Bnierz?= Date: Tue, 29 Apr 2025 14:20:39 +0200 Subject: [PATCH] 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 --- admin/background_jobs.pl | 17 +++++++++++++++++ .../prog/en/modules/admin/background_jobs.tt | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/admin/background_jobs.pl b/admin/background_jobs.pl index dd4f56963a..d51877545b 100755 --- a/admin/background_jobs.pl +++ b/admin/background_jobs.pl @@ -79,4 +79,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; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt index 0c2490f012..c9ba94cd17 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt @@ -227,6 +227,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) { -- 2.47.2