From 5fb0e60fab7c5037396deb3b82dede295827eadd Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 7 Jun 2021 00:14:55 +0000 Subject: [PATCH] Bug 28489: Put CGI::Session::Serialize::yamlxs in lib directory This patch adds a "lib" directory to the source tree which gets mapped to the same directory as "C4" and "Koha" for single and standard installations. CGI::Session::Serialize::yamlxs is put into this "lib" directory. This patch also includes some changes so that dev/git installations work as well. --- C4/Auth.pm | 34 +++++----------------------------- Makefile.PL | 4 +++- debian/scripts/koha-functions.sh | 2 +- lib/CGI/Session/Serialize/yamlxs.pm | 22 ++++++++++++++++++++++ 4 files changed, 31 insertions(+), 31 deletions(-) create mode 100644 lib/CGI/Session/Serialize/yamlxs.pm diff --git a/C4/Auth.pm b/C4/Auth.pm index cb35984b2e..2a2e3b6779 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1,31 +1,3 @@ -package CGI::Session::Serialize::yamlxs; -# Proof of concept: CGI::Session::Serialize::yamlxs for CGI::Session: - -use strict; -use warnings; - -# hacky hack to trick CGI::Session loader for serializers not to die in its "require": -$INC{'CGI/Session/Serialize/yamlxs.pm'} = '1'; - -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]; -} -# ******************************************************************** - - - package C4::Auth; # Copyright 2000-2002 Katipo Communications @@ -1899,7 +1871,11 @@ sub _get_session_params { sub get_session { my $sessionID = shift; my $params = _get_session_params(); - return CGI::Session->new( $params->{dsn}, $sessionID, $params->{dsn_args} ); + my $session = CGI::Session->new( $params->{dsn}, $sessionID, $params->{dsn_args} ); + if ( ! $session ){ + die CGI::Session->errstr(); + } + return $session; } diff --git a/Makefile.PL b/Makefile.PL index 9ade47696c..d261fed19e 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -334,6 +334,7 @@ my $target_map = { './koha-tmpl/opac-tmpl' => {target => 'OPAC_TMPL_DIR', trimdir => -1}, './kohaversion.pl' => 'INTRANET_CGI_DIR', './labels' => 'INTRANET_CGI_DIR', + './lib' => {target => 'PERL_MODULE_DIR', trimdir => -1}, './mainpage.pl' => 'INTRANET_CGI_DIR', './Makefile.PL' => 'NONE', './MANIFEST.SKIP' => 'NONE', @@ -1464,7 +1465,8 @@ sub get_target_directories { $skipdirs{'OPAC_TMPL_DIR'} = 1; $dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir($curdir, 'koha-tmpl'); $skipdirs{'OPAC_WWW_DIR'} = 1; - $dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir($curdir); + #NOTE: We're hacking the dirmap here, so that PERL_MODULE_DIR tokens get rewritten correctly for git installs + $dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir($curdir) . ":" . File::Spec->catdir($curdir) . "/lib"; $skipdirs{'PERL_MODULE_DIR'} = 1; $dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc'); $dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'zebradb'); diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh index f82ebfcc80..8888ad6290 100755 --- a/debian/scripts/koha-functions.sh +++ b/debian/scripts/koha-functions.sh @@ -330,7 +330,7 @@ adjust_paths_dev_install() if [ "$dev_install" != "" ] && [ "$dev_install" != "0" ]; then DEV_INSTALL=1 KOHA_HOME=$(run_safe_xmlstarlet $instancename intranetdir) - PERL5LIB=$KOHA_HOME + PERL5LIB="$KOHA_HOME:$KOHA_HOME/lib" else DEV_INSTALL="" fi diff --git a/lib/CGI/Session/Serialize/yamlxs.pm b/lib/CGI/Session/Serialize/yamlxs.pm new file mode 100644 index 0000000000..77d2a8d51a --- /dev/null +++ b/lib/CGI/Session/Serialize/yamlxs.pm @@ -0,0 +1,22 @@ +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; -- 2.11.0