[Rt-commit] rt branch, 5.0/json-serializer-encoding, created. rt-5.0.0alpha1-431-g6f31268c64

? sunnavy sunnavy at bestpractical.com
Tue May 12 16:32:18 EDT 2020


The branch, 5.0/json-serializer-encoding has been created
        at  6f31268c64984e10de16297501c2cc3b5a63126d (commit)

- Log -----------------------------------------------------------------
commit 6f31268c64984e10de16297501c2cc3b5a63126d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 13 03:17:01 2020 +0800

    Explicitly encode to UTF-8 for json serializer only when it's Pg/Oracle
    
    Serializer generates UTF-8 decoded string when it's Pg/Oracle, which is
    different from MySQL/SQLite.
    
    We need to check database type instead of the utf8 flag of json encoded
    output is because JSON doesn't care what data it gets and the utf8 flag
    totally depends on the JSON object(i.e. whether "utf8" is called or not)
    
    See also 80f172bba3

diff --git a/lib/RT/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
index 5cda5057d9..961e874fa9 100644
--- a/lib/RT/Migrate/Serializer/JSON.pm
+++ b/lib/RT/Migrate/Serializer/JSON.pm
@@ -156,7 +156,9 @@ sub PushBasics {
 
 sub JSON {
     my $self = shift;
-    return $self->{JSON} ||= JSON->new->utf8->pretty->canonical;
+    $self->{JSON} ||= JSON->new->pretty->canonical;
+    $self->{JSON} = $self->{JSON}->utf8 if RT->Config->Get('DatabaseType') =~ /Pg|Oracle/;
+    return $self->{JSON};
 }
 
 sub OpenFile {

-----------------------------------------------------------------------


More information about the rt-commit mailing list