diff --git a/misc/workers/background_jobs_worker.pl b/misc/workers/background_jobs_worker.pl index 7d2c4f3876..27ae8ff9be 100755 --- a/misc/workers/background_jobs_worker.pl +++ b/misc/workers/background_jobs_worker.pl @@ -127,10 +127,11 @@ while (1) { # FIXME This means we need to have create the DB entry before # It could work in a first step, but then we will want to handle job that will be created from the message received - my $job = Koha::BackgroundJobs->find($args->{job_id}); + my $job = Koha::BackgroundJobs->search( { id => $args->{job_id}, status => 'new' } )->next; - unless ( $job ) { - Koha::Logger->get({ interface => 'worker' })->warn(sprintf "No job found for id=%s", $args->{job_id}); + unless( $job ) { + Koha::Logger->get( { interface => 'worker' } ) + ->warn( sprintf "Job %s not found, or has wrong status", $args->{job_id} ); next; }