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 <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2023-03-24 11:17:58 +01:00 committed by Tomas Cohen Arazi
parent f99bcfb652
commit 15e234e596
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -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
});
},
};