From 508ef298f76886fb4bae73a28d6e3ca7ca2b2831 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 27 Jul 2021 18:19:18 +0200 Subject: [PATCH] Bug 28445: Fix encoding issue with the background job's report Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- Koha/BackgroundJob.pm | 5 +++-- Koha/BackgroundJob/BatchUpdateItem.pm | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index ab55376d33..c5cfd90899 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -17,6 +17,7 @@ package Koha::BackgroundJob; use Modern::Perl; use JSON qw( decode_json encode_json ); +use Encode qw( encode_utf8 ); use Carp qw( croak ); use Net::Stomp; use Try::Tiny qw( catch try ); @@ -182,7 +183,7 @@ sub messages { my ( $self ) = @_; my @messages; - my $data_dump = decode_json $self->data; + my $data_dump = decode_json encode_utf8 $self->data; if ( exists $data_dump->{messages} ) { @messages = @{ $data_dump->{messages} }; } @@ -199,7 +200,7 @@ Report of the job. sub report { my ( $self ) = @_; - my $data_dump = decode_json $self->data; + my $data_dump = decode_json encode_utf8 $self->data; return $data_dump->{report} || {}; } diff --git a/Koha/BackgroundJob/BatchUpdateItem.pm b/Koha/BackgroundJob/BatchUpdateItem.pm index 405e71456f..1dbc922682 100644 --- a/Koha/BackgroundJob/BatchUpdateItem.pm +++ b/Koha/BackgroundJob/BatchUpdateItem.pm @@ -17,6 +17,7 @@ package Koha::BackgroundJob::BatchUpdateItem; use Modern::Perl; use JSON qw( encode_json decode_json ); +use Encode qw( encode_utf8 ); use List::MoreUtils qw( uniq ); use Try::Tiny; @@ -138,7 +139,7 @@ sub process { if ( $_ =~ /Rollback failed/ ); # Rollback failed }; - my $job_data = decode_json $job->data; + my $job_data = decode_json encode_utf8 $job->data; $job_data->{report} = $report; $job->ended_on(dt_from_string)->data( encode_json $job_data); -- 2.39.5