@@ -, +, @@ --- 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(-) --- a/Koha/BackgroundJob.pm +++ a/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 --- a/Koha/BackgroundJob/BatchUpdateAuthority.pm +++ a/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 --- a/Koha/BackgroundJob/BatchUpdateBiblio.pm +++ a/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 --- a/misc/background_jobs_worker.pl +++ a/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 --