From e4b639f9335b5134f1cc5b19d71ff4ba202c84d9 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 25 Mar 2022 10:02:59 -0300 Subject: [PATCH] Bug 30350: Avoid hardcoding job types in background_jobs_worker.pl Currently, background_jobs_worker.pl has a hardcoded list of jobs it can process. Koha::BackgroundJob already has a method that can be used to extract such list. Using it would avoid having to maintain two lists, and it would also make it easier to inject plugin tasks as well. To test: 1. Apply the patch 2. Restart the koha-worker 3. Run one of the batch operations that make use of the background jobs (I used batch item delete) => SUCCESS: Things work, no change 4. Sign off :-D Signed-off-by: Tomas Cohen Arazi JD amended patch -my @job_types = keys %{Koha::BackgroundJob::type_to_class_mapping}; +my @job_types = keys %{Koha::BackgroundJob::type_to_class_mapping()}; To remove the following error: Ambiguous use of %{Koha::BackgroundJob::type_to_class_mapping} resolved to %Koha::BackgroundJob::type_to_class_mapping Signed-off-by: Jonathan Druart --- misc/background_jobs_worker.pl | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/misc/background_jobs_worker.pl b/misc/background_jobs_worker.pl index 5a84d342baa..5d7663c8ccb 100755 --- a/misc/background_jobs_worker.pl +++ b/misc/background_jobs_worker.pl @@ -28,15 +28,7 @@ try { warn sprintf "Cannot connect to the message broker, the jobs will be processed anyway (%s)", $_; }; -my @job_types = qw( - batch_biblio_record_modification - batch_authority_record_modification - batch_item_record_modification - batch_biblio_record_deletion - batch_authority_record_deletion - batch_item_record_deletion - batch_hold_cancel -); +my @job_types = keys %{Koha::BackgroundJob::type_to_class_mapping()}; if ( $conn ) { # FIXME cf note in Koha::BackgroundJob about $namespace -- 2.25.1