From 6fb877d50b6cdaa78a84be0616083feca80143b1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 7 Jun 2021 13:53:05 +0200 Subject: [PATCH] Bug 17427: Use our own YAML::XS serializer Signed-off-by: Kyle M Hall --- C4/Auth.pm | 2 +- lib/CGI/Session/Serialize/yamlxs.pm | 22 ---------------------- lib/Data/Session/Serialize/yamlxs.pm | 27 +++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 23 deletions(-) delete mode 100644 lib/CGI/Session/Serialize/yamlxs.pm create mode 100644 lib/Data/Session/Serialize/yamlxs.pm diff --git a/C4/Auth.pm b/C4/Auth.pm index 2c57c2cdc7..e07445b496 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1834,7 +1834,7 @@ will be created. sub _get_session_params { my $storage_method = C4::Context->preference('SessionStorage'); - my $serializer = q{serialize:JSON}; + my $serializer = q{serialize:yamlxs}; if ( $storage_method eq 'mysql' ) { my $dbh = C4::Context->dbh; # Note that the doc is wrong, type is required, if not provided it default to File diff --git a/lib/CGI/Session/Serialize/yamlxs.pm b/lib/CGI/Session/Serialize/yamlxs.pm deleted file mode 100644 index 88d25e704d..0000000000 --- a/lib/CGI/Session/Serialize/yamlxs.pm +++ /dev/null @@ -1,22 +0,0 @@ -package CGI::Session::Serialize::yamlxs; - -use strict; -use warnings; - -use CGI::Session::ErrorHandler; -use YAML::XS; - -$CGI::Session::Serialize::yamlxs::VERSION = '0.1'; -@CGI::Session::Serialize::yamlxs::ISA = ( "CGI::Session::ErrorHandler" ); - -sub freeze { - my ($self, $data) = @_; - return YAML::XS::Dump($data); -} - -sub thaw { - my ($self, $string) = @_; - return (YAML::XS::Load($string))[0]; -} - -1; diff --git a/lib/Data/Session/Serialize/yamlxs.pm b/lib/Data/Session/Serialize/yamlxs.pm new file mode 100644 index 0000000000..8adbaba8a8 --- /dev/null +++ b/lib/Data/Session/Serialize/yamlxs.pm @@ -0,0 +1,27 @@ +package Data::Session::Serialize::yamlxs; + +use parent 'Data::Session::Base'; +no autovivification; +use strict; +use warnings; + +use YAML::XS; + +our $VERSION = '0.1'; + +sub freeze { + my($self, $data) = @_; + return YAML::XS::Dump($data); +} + +sub new { + my($class) = @_; + return bless({}, $class); +} + +sub thaw { + my ($self, $string) = @_; + return (YAML::XS::Load($string))[0]; +} + +1; -- 2.30.2