From 644d75fc5bbba6beab6234812bf72788a43d6d59 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 --- 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 00000000000..94e2cd0ba11 --- /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.25.1