From 5770e144a11dd5695cafd1e0295754205700b453 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 --- 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 ab55376d336..c5cfd90899e 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 405e71456f1..1dbc9226826 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.25.1