Bug 32393: Deal with the DB fallback part
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 24 Jan 2023 08:11:25 +0000 (09:11 +0100)
committerLucas Gass <lucas@bywatersolutions.com>
Wed, 1 Feb 2023 18:26:47 +0000 (18:26 +0000)
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 85c330d8f2ca6246cf3619c8075907cce8387be0)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
(cherry picked from commit 54e87225eac2c70aa6487b6f614bddc3083a774b)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
misc/background_jobs_worker.pl

index 059d706..44f7990 100755 (executable)
@@ -119,8 +119,17 @@ while (1) {
     } else {
         my $jobs = Koha::BackgroundJobs->search({ status => 'new', queue => \@queues });
         while ( my $job = $jobs->next ) {
-            my $args = $job->json->decode($job->data);
+            my $args = try {
+                $job->json->decode($job->data);
+            } catch {
+                Koha::Logger->get->warn(sprintf "Cannot decode data for job id=%s", $job->id);
+                $job->status('failed')->store;
+            };
+
+            next unless $args;
+
             process_job( $job, { job_id => $job->id, %$args } );
+
         }
         sleep 10;
     }