From 47db7248a28aa282a627c0e7b4afb11767b5b73e Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Sat, 6 Oct 2007 16:56:26 -0500 Subject: [PATCH] Setting up a system preference to choose whether CGI::Session uses mysql, or temporary files Need to add it to a couple more places in C4::Auth Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Auth.pm | 15 ++++++++++----- installer/data/en/mandatory/sysprefs.sql | 5 +++-- kohaversion.pl | 2 +- updater/updatedatabase | 6 ++++++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index fbf4417895..e11c5826bf 100755 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -260,8 +260,7 @@ sub get_template_and_user { ); } else { - warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" - unless ( $in->{'type'} eq 'opac' ); + warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' ); my $LibraryNameTitle = C4::Context->preference("LibraryName"); $LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi; $LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg; @@ -378,7 +377,6 @@ sub checkauth { # If Version syspref is unavailable, it means Koha is beeing installed, # and so we must redirect to OPAC maintenance page or to the WebInstaller - warn "about to check version"; unless (C4::Context->preference('Version')) { if ($type ne 'opac') { warn "Install required, redirecting to Installer"; @@ -407,8 +405,15 @@ sub checkauth { $loggedin = 1; } elsif ( $sessionID = $query->cookie("CGISESSID")) { -# my $session = new CGI::Session("driver:MySQL", $sessionID, {Handle=>$dbh}); - my $session = new CGI::Session("driver:File", $sessionID, {Directory=>'/tmp'}); + my $storage_method = C4::Context->preference('SessionStorage'); + my $session; + if ($storage_method eq 'mysql'){ + $session = new CGI::Session("driver:MySQL", $sessionID, {Handle=>$dbh}); + } + else { + # catch all defaults to tmp should work on all systems + $session = new CGI::Session("driver:File", $sessionID, {Directory=>'/tmp'}); + } C4::Context->_new_userenv($sessionID); if ($session){ C4::Context::set_userenv( diff --git a/installer/data/en/mandatory/sysprefs.sql b/installer/data/en/mandatory/sysprefs.sql index 1a0e37b7e2..e5946389b2 100644 --- a/installer/data/en/mandatory/sysprefs.sql +++ b/installer/data/en/mandatory/sysprefs.sql @@ -99,8 +99,9 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('z3950NormalizeAuthor','0','If ON, Personal Name Authorities will replace authors in biblio.author','','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ReservesNeedReturns','0','If ON, a hold placed on an item available in this library must be checked-in, otherwise, a hold on a specific item, that is in the library & available is considered available','','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('DebugLevel','2','Define the level of debugging information sent to the browser when errors are encountered (set to 0 in production). 0=none, 1=some, 2=most','0|1|2','Choice'); - INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('NoZebra','1','If ON, Zebra indexing is turned off, simpler setup, but slower searches','','YesNo'); - INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('NoZebraIndexes','0','Enter a specific hash for NoZebra indexes. Enter : \'indexname\' => \'100a,245a,500*\',\'index2\' => \'...\'','','Free'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('SessionStorage','mysql','Use mysql or a temporary file for storing session data','mysql|tmp','Choice'); + + diff --git a/kohaversion.pl b/kohaversion.pl index 940416dbb3..b9098a82e8 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -8,7 +8,7 @@ # and is automatically called by Auth.pm when needed. sub kohaversion { - return "3.00.00.006"; + return "3.00.00.007"; } 1; diff --git a/updater/updatedatabase b/updater/updatedatabase index bc30fdd8a8..327bd2a10c 100755 --- a/updater/updatedatabase +++ b/updater/updatedatabase @@ -2236,6 +2236,12 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.00.00.007"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SessionStorage','mysql','Use mysql or a temporary file for storing session data','mysql|tmp','Choice')"); + print "Upgrade to $DBversion done (set SessionStorage variable)\n"; + SetVersion ($DBversion); +} =item DropAllForeignKeys($table) -- 2.39.5