From 2af11ccb92d31f6304b7450d2d8a35dae5a13398 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 --- 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 5063754ff00..8976afc866d 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1847,7 +1847,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 77d2a8d51a2..00000000000 --- 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 00000000000..8adbaba8a88 --- /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.20.1