From a13f3ae329d554ff5bc960345c94b8174367c901 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 14 Jan 2021 15:30:37 +0000 Subject: [PATCH] Bug 27434: POC --- Koha/BackgroundJob.pm | 13 ++++++++----- Koha/BackgroundJob/BatchUpdateAuthority.pm | 2 +- Koha/BackgroundJob/BatchUpdateBiblio.pm | 2 +- misc/background_jobs_worker.pl | 3 ++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index d375dfa0d5..3b31b9a109 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -137,11 +137,14 @@ sub process { my ( $self, $args ) = @_; my $job_type = $self->type; - return $job_type eq 'batch_biblio_record_modification' - ? Koha::BackgroundJob::BatchUpdateBiblio->process($args) - : $job_type eq 'batch_authority_record_modification' - ? Koha::BackgroundJob::BatchUpdateAuthority->process($args) - : Koha::Exceptions::Exception->throw('->process called without valid job_type'); + my $class = "Koha::BackgroundJob::${job_type}"; + try{ + return $class->process( $args ); + } catch { + Koha::Exceptions::Exception->throw('->process called without valid job_type'); + }; + + } =head3 job_type diff --git a/Koha/BackgroundJob/BatchUpdateAuthority.pm b/Koha/BackgroundJob/BatchUpdateAuthority.pm index 24f1e9a400..660b59cd60 100644 --- a/Koha/BackgroundJob/BatchUpdateAuthority.pm +++ b/Koha/BackgroundJob/BatchUpdateAuthority.pm @@ -43,7 +43,7 @@ Define the job type of this job: batch_authority_record_modification =cut sub job_type { - return 'batch_authority_record_modification'; + return 'BatchUpdateAuthority'; } =head3 process diff --git a/Koha/BackgroundJob/BatchUpdateBiblio.pm b/Koha/BackgroundJob/BatchUpdateBiblio.pm index 7cb7969474..9959b8f434 100644 --- a/Koha/BackgroundJob/BatchUpdateBiblio.pm +++ b/Koha/BackgroundJob/BatchUpdateBiblio.pm @@ -42,7 +42,7 @@ Define the job type of this job: batch_biblio_record_modification =cut sub job_type { - return 'batch_biblio_record_modification'; + return 'BatchUpdateBiblio'; } =head3 process diff --git a/misc/background_jobs_worker.pl b/misc/background_jobs_worker.pl index 0520189fa5..4bbaa278ee 100755 --- a/misc/background_jobs_worker.pl +++ b/misc/background_jobs_worker.pl @@ -28,7 +28,8 @@ 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 ); +# FIXME Job types should be stored in a table so that plugins can register new job types as well +my @job_types = qw( BatchUpdateBiblio BatchUpdateAuthority ); if ( $conn ) { # FIXME cf note in Koha::BackgroundJob about $namespace -- 2.11.0