Bugzilla – Attachment 115164 Details for
Bug 27434
Background Jobs should use classes as job types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27434: POC
Bug-27434-POC.patch (text/plain), 2.78 KB, created by
Nick Clemens (kidclamp)
on 2021-01-14 15:30:58 UTC
(
hide
)
Description:
Bug 27434: POC
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-01-14 15:30:58 UTC
Size:
2.78 KB
patch
obsolete
>From a13f3ae329d554ff5bc960345c94b8174367c901 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >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
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27434
: 115164