From 4634494df300592806ce37fafcb982c6e307a2d2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 24 Mar 2023 11:17:58 +0100 Subject: [PATCH] Bug 32745: Adjust context for invalid background jobs We had some problems recently and it's possible to have background_jobs.context=NULL But the REST API specs is expecting an object. We could either modify the specs, or adjust the incorrect entries in DB, which is IMO better. Test plan: 0. Don't apply the patch 1. Create some background jobs 2. Set context to NULL UPDATE background_jobs SET context=NULL; 3. List the jobs and note the datatable error, and the error in Koha log OpenAPI >>> GET api/v1/jobs [{"message":"Expected object - got null.","path":"\/body\/0\/context"},{"message":"Expected object - got null.","path":"\/body\/1\/context"}] 4. Apply the patch 5. Run `updatedatabase` 6. Confirm that the list and detail view are not working correctly Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 15e234e5963c9c426541c76d599e5b561fd542ad) Signed-off-by: Martin Renvoize --- installer/data/mysql/atomicupdate/bug_32745.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_32745.pl diff --git a/installer/data/mysql/atomicupdate/bug_32745.pl b/installer/data/mysql/atomicupdate/bug_32745.pl new file mode 100755 index 0000000000..94e2cd0ba1 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_32745.pl @@ -0,0 +1,15 @@ +use Modern::Perl; + +return { + bug_number => "32745", + description => "Update context={} for invalid background jobs", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + $dbh->do(q{ + UPDATE background_jobs + SET context="{}" + WHERE context IS NULL + }); + }, +}; -- 2.39.5