Skip Menu |
 

This queue is for tickets about the CGI-Session CPAN distribution.

Report information
The Basics
Id: 5318
Status: resolved
Priority: 0/
Queue: CGI-Session

People
Owner: MARKSTOS [...] cpan.org
Requestors: blackbird [...] chatterpages.de
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 3.95
Fixed in: (no value)



Subject: Cannot set table name (CGI::Session::MySQL)
Download (untitled) / with headers
text/plain 257b
I tried to set a session table name for CGI::Session::MySQL as shown in the documentation, but it seems to be ignored. use CGI::Session; $CGI::Session::MySQL::TABLE_NAME = 'my_sessions'; The module still uses table 'sessions'. Greetings, Bianka (Germany)
Download (untitled) / with headers
text/plain 139b
Hello again, changing $TABLE_NAME = 'sessions'; to $TABLE_NAME ||= 'sessions'; works. (File: CGI/Session/MySQL.pm) Greetings, Bianka
From: markstos [...] cpan.org
Download (untitled) / with headers
text/plain 547b
[guest - Fri Feb 13 10:58:20 2004]: Show quoted text
> I tried to set a session table name for CGI::Session::MySQL as shown > in the documentation, but it seems to be ignored. > > use CGI::Session; > $CGI::Session::MySQL::TABLE_NAME = 'my_sessions'; > > The module still uses table 'sessions'. > > Greetings, Bianka (Germany)
Hello, I've created the following patch against my branch of 4.00_08 that I believe addresses this. Assuming these changes are integrated, this bug can be considered resolved. Thanks for the report! Mark
Download TABLE.patch
text/x-diff 2.7k
Mon Jul 4 13:46:48 EST 2005 Mark Stosberg <mark@summersault.com> * Add code and tests for $CGI::Session::MySQL::TABLE_NAME (which worked in 3.x) diff -rN -u old-cgi-session/Changes new-cgi-session/Changes --- old-cgi-session/Changes 2005-07-04 15:09:18.000000000 -0500 +++ new-cgi-session/Changes 2005-07-04 13:40:28.000000000 -0500 @@ -3,6 +3,8 @@ * FIX: Added back is_new() for compatibility with 3.95. (Mark Stosberg) * FIX: Support for CGI::Simple is confirmed, resolving RT#6141 (Mark Stosberg) + * FIX: Add code and tests for $CGI::Session::MySQL::TABLE_NAME, + which worked in 3.x (Mark Stosberg) 4.00_08 - Tuesday, March 15, 2005 diff -rN -u old-cgi-session/lib/CGI/Session/Driver/mysql.pm new-cgi-session/lib/CGI/Session/Driver/mysql.pm --- old-cgi-session/lib/CGI/Session/Driver/mysql.pm 2005-07-04 15:09:18.000000000 -0500 +++ new-cgi-session/lib/CGI/Session/Driver/mysql.pm 2005-07-04 13:39:11.000000000 -0500 @@ -30,6 +30,15 @@ return 1; } +# If the table name hasn't been defined yet, check this location for 3.x compatibility +sub table_name { + my $self = shift; + unless (defined $self->{TableName}) { + $self->{TableName} = $CGI::Session::MySQL::TABLE_NAME; + } + return $self->SUPER::table_name(@_); +} + 1; __END__; @@ -60,6 +69,14 @@ # is the same as: $s = new CGI::Session( "driver:mysql", $sid, {DataSource=>'dbi:mysql:shopping_cart'}); +=head2 BACKWARDS COMPATIBILITY + +For backwards compatibility, you can also set the table like this before +calling C<new()>. However, it is not recommended because it can cause conflicts +in a persistent environment. + + $CGI::Session::MySQL::TABLE_NAME = 'my_sessions'; + =head1 LICENSING For support and licensing see L<CGI::Session|CGI::Session>. diff -rN -u old-cgi-session/t/g4_mysql.t new-cgi-session/t/g4_mysql.t --- old-cgi-session/t/g4_mysql.t 2005-07-04 15:09:18.000000000 -0500 +++ new-cgi-session/t/g4_mysql.t 2005-07-04 13:34:07.000000000 -0500 @@ -52,5 +52,20 @@ args=>{Handle=>$dbh, TableName=>$dsn{TableName}}); -plan tests => $t->number_of_tests; +plan tests => $t->number_of_tests + 2; $t->run(); + +{ + # This was documented to work in 3.95 and should be supported for compatibility + my $obj; + eval { + # test.sessions will refer to the same 'sessions' table but is a unique name to test with + $CGI::Session::MySQL::TABLE_NAME = 'test.sessions'; + my $avoid_warning = $CGI::Session::MySQL::TABLE_NAME; + require CGI::Session::Driver::mysql; + $obj = CGI::Session::Driver::mysql->new( {Handle=>$dbh} ); + }; + is($@,'', 'survived eval'); + is($obj->table_name, 'test.sessions', "setting table name through CGI::Session::MySQL::TABLE_NAME works"); +} +


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.