use UTF8 JSON encoding and decoding universally
fixed: Import/Export of packages with international text is broken
This commit is contained in:
parent
35bfeac0ef
commit
9ed284beec
16 changed files with 42 additions and 40 deletions
|
|
@ -25,7 +25,7 @@ use WebGUI::DateTime;
|
|||
use DateTime::TimeZone;
|
||||
|
||||
use LWP::UserAgent;
|
||||
use JSON qw(to_json from_json);
|
||||
use JSON qw(encode_json decode_json);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -92,8 +92,8 @@ sub execute {
|
|||
my $eventList = [];
|
||||
my $feedList;
|
||||
if ($instance->getScratch('events')) {
|
||||
$eventList = from_json($instance->getScratch('events'));
|
||||
$feedList = from_json($instance->getScratch('feeds'));
|
||||
$eventList = decode_json($instance->getScratch('events'));
|
||||
$feedList = decode_json($instance->getScratch('feeds'));
|
||||
}
|
||||
else {
|
||||
my $ua = LWP::UserAgent->new(agent => "WebGUI");
|
||||
|
|
@ -356,8 +356,8 @@ sub execute {
|
|||
}
|
||||
while (@$eventList) {
|
||||
if ($startTime + 55 < time()) {
|
||||
$instance->setScratch('events', to_json($eventList));
|
||||
$instance->setScratch('feeds', to_json($feedList));
|
||||
$instance->setScratch('events', encode_json($eventList));
|
||||
$instance->setScratch('feeds', encode_json($feedList));
|
||||
return $self->WAITING;
|
||||
}
|
||||
my $eventData = shift @$eventList;
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ sub execute {
|
|||
|
||||
# if there are urls left, we need to process again
|
||||
if (scalar(@syndicatedUrls) > 0) {
|
||||
$instance->setScratch("syndicatedUrls", JSON::to_json(\@syndicatedUrls));
|
||||
$instance->setScratch("syndicatedUrls", JSON::encode_json(\@syndicatedUrls));
|
||||
return $self->WAITING;
|
||||
}
|
||||
$instance->deleteScratch("syndicatedUrls");
|
||||
|
|
@ -120,7 +120,7 @@ sub getSyndicatedUrls {
|
|||
my $instance = shift;
|
||||
my $syndicatedUrls = $instance->getScratch("syndicatedUrls");
|
||||
if ($syndicatedUrls) {
|
||||
return JSON::from_json($syndicatedUrls);
|
||||
return JSON::decode_json($syndicatedUrls);
|
||||
}
|
||||
|
||||
my $urls = [];
|
||||
|
|
@ -131,7 +131,7 @@ sub getSyndicatedUrls {
|
|||
foreach my $asset (@$assets) {
|
||||
push @$urls, split(/\s+/, $asset->getRssUrl);
|
||||
}
|
||||
$instance->setScratch("syndicatedUrls", JSON::to_json($urls));
|
||||
$instance->setScratch("syndicatedUrls", JSON::encode_json($urls));
|
||||
return $urls;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ sub get {
|
|||
my $name = shift;
|
||||
if ($name eq "parameters") {
|
||||
if (exists $self->{_data}{parameters} && $self->{_data}{parameters} ne "") {
|
||||
my $parameters = JSON::from_json($self->{_data}{$name});
|
||||
my $parameters = JSON::decode_json($self->{_data}{$name});
|
||||
return $parameters->{parameters};
|
||||
}
|
||||
else {
|
||||
|
|
@ -303,7 +303,7 @@ sub set {
|
|||
$self->{_data}{className} = (exists $properties->{className}) ? $properties->{className} : $self->{_data}{className};
|
||||
$self->{_data}{methodName} = (exists $properties->{methodName}) ? $properties->{methodName} : $self->{_data}{methodName};
|
||||
if (exists $properties->{parameters}) {
|
||||
$self->{_data}{parameters} = JSON->new->pretty->encode({parameters => $properties->{parameters}});
|
||||
$self->{_data}{parameters} = JSON->new->utf8->pretty->encode({parameters => $properties->{parameters}});
|
||||
}
|
||||
$self->{_data}{enabled} = 0 unless ($self->{_data}{workflowId});
|
||||
my $spectre = WebGUI::Workflow::Spectre->new($self->session);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ sub create {
|
|||
my ($isSingleton) = $session->db->quickArray("select count(*) from Workflow where workflowId=? and
|
||||
mode='singleton'",[$properties->{workflowId}]);
|
||||
my $params = (exists $properties->{parameters})
|
||||
? JSON->new->pretty->encode({parameters => $properties->{parameters}})
|
||||
? JSON->new->utf8->pretty->encode({parameters => $properties->{parameters}})
|
||||
: undef;
|
||||
my ($count) = $session->db->quickArray("select count(*) from WorkflowInstance where workflowId=? and parameters=?",[$properties->{workflowId},$params]);
|
||||
return undef if ($isSingleton && $count);
|
||||
|
|
@ -148,7 +148,7 @@ sub get {
|
|||
my $name = shift;
|
||||
if ($name eq "parameters") {
|
||||
if (exists $self->{_data}{parameters}) {
|
||||
my $parameters = JSON::from_json($self->{_data}{$name});
|
||||
my $parameters = JSON::decode_json($self->{_data}{$name});
|
||||
return $parameters->{parameters};
|
||||
}
|
||||
else {
|
||||
|
|
@ -421,7 +421,7 @@ sub set {
|
|||
$self->{_data}{className} = (exists $properties->{className}) ? $properties->{className} : $self->{_data}{className};
|
||||
$self->{_data}{methodName} = (exists $properties->{methodName}) ? $properties->{methodName} : $self->{_data}{methodName};
|
||||
if (exists $properties->{parameters}) {
|
||||
$self->{_data}{parameters} = JSON->new->pretty->encode({parameters => $properties->{parameters}});
|
||||
$self->{_data}{parameters} = JSON->new->utf8->pretty->encode({parameters => $properties->{parameters}});
|
||||
}
|
||||
$self->{_data}{currentActivityId} = (exists $properties->{currentActivityId}) ? $properties->{currentActivityId} : $self->{_data}{currentActivityId};
|
||||
$self->{_data}{lastUpdate} = time();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue