Bug 11944: Fix suggestion at the OPAC for perl v5.10

Without this patch and using Perl v5.10, on adding a suggestion at the
OPAC, the script explodes with the following error:
"cannot decode string with wide characters".

With this patch, all is fine using Perl v5.10 and v5.18.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
Jonathan Druart 2014-08-18 17:33:32 +02:00 committed by Tomas Cohen Arazi
parent 42a8082c8f
commit a5ee0f3d70
1 changed files with 3 additions and 1 deletions

View File

@ -19,6 +19,7 @@ use strict;
use warnings;
use CGI qw ( -utf8 );
use Encode qw( encode );
use C4::Auth; # get_template_and_user
use C4::Members;
use C4::Branch;
@ -91,7 +92,8 @@ if ( $op eq "add_confirm" ) {
else {
my $scrubber = C4::Scrubber->new();
foreach my $suggest (keys %$suggestion){
$suggestion->{$suggest} = $scrubber->scrub($suggestion->{$suggest});
# Don't know why the encode is needed for Perl v5.10 here
$suggestion->{$suggest} = Encode::encode("utf8", $scrubber->scrub($suggestion->{$suggest}) );
}
$suggestion->{suggesteddate} = dt_from_string;
$suggestion->{branchcode} = $input->param('branchcode') || C4::Context->userenv->{"branch"};