From d7c8de7e7fe917d5718fdce9a250814952b5221c Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 12 May 2022 08:38:15 +0000 Subject: [PATCH] Bug 30734: Fix BackgroundJob.t Added test for empty string or undefined. We could still consider evaling the json operations. Test plan: Run t/db_dependent/Koha/BackgroundJob.t Signed-off-by: Marcel de Rooy Signed-off-by: Fridolin Somers --- Koha/BackgroundJob.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index a84ca42c58..517c54f010 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -245,7 +245,7 @@ Returns the decoded JSON contents from $self->data. sub decoded_data { my ($self) = @_; - return decode_json($self->data); + return $self->data ? decode_json( $self->data ) : undef; } =head3 set_encoded_data @@ -259,7 +259,7 @@ Serializes I<$data> as a JSON string and sets the I attribute with it. sub set_encoded_data { my ( $self, $data ) = @_; - return $self->data( encode_json($data) ); + return $self->data( $data ? encode_json($data) : undef ); } =head3 job_type -- 2.39.5