[Rt-commit] r5871 - in rt/branches/3.6-RELEASE: .
jesse at bestpractical.com
jesse at bestpractical.com
Wed Sep 6 15:07:17 EDT 2006
Author: jesse
Date: Wed Sep 6 15:07:16 2006
New Revision: 5871
Modified:
rt/branches/3.6-RELEASE/ (props changed)
rt/branches/3.6-RELEASE/html/Elements/SetupSessionCookie
Log:
r27202 at pinglin: jesse | 2006-09-06 14:59:10 -0400
* Handle Apache::Session database errors a bit more gracefully
Modified: rt/branches/3.6-RELEASE/html/Elements/SetupSessionCookie
==============================================================================
--- rt/branches/3.6-RELEASE/html/Elements/SetupSessionCookie (original)
+++ rt/branches/3.6-RELEASE/html/Elements/SetupSessionCookie Wed Sep 6 15:07:16 2006
@@ -46,68 +46,77 @@
<%init>
return if $m->is_subrequest; # avoid reentrancy, as suggested by masonbook
-my %cookies = CGI::Cookie->fetch();
-my $cookiename = "RT_SID_".$RT::rtname.".".$ENV{'SERVER_PORT'};
-my %backends = (
- mysql => 'Apache::Session::MySQL',
- Pg => 'Apache::Session::Postgres',
-# Oracle => 'Apache::Session::Oracle',
+my %cookies = CGI::Cookie->fetch();
+my $cookiename = "RT_SID_" . $RT::rtname . "." . $ENV{'SERVER_PORT'};
+my %backends = (
+ mysql => 'Apache::Session::MySQL',
+ Pg => 'Apache::Session::Postgres',
+
+ # Oracle => 'Apache::Session::Oracle',
) unless $RT::WebSessionClass;
-my $session_class = $RT::WebSessionClass || $backends{$RT::DatabaseType} || 'Apache::Session::File';
-my $pm = "$session_class.pm"; $pm =~ s|::|/|g; require $pm;
+my $session_class = $RT::WebSessionClass
+ || $backends{$RT::DatabaseType}
+ || 'Apache::Session::File';
+my $pm = "$session_class.pm";
+$pm =~ s|::|/|g;
+require $pm;
+
+# morning bug avoidance attempt -- pdh 20030815
+unless ( $RT::Handle->dbh && $RT::Handle->dbh->ping ) {
+ $RT::Handle->Connect();
+}
+eval {
+ tie %session, $session_class,
+ $SessionCookie
+ || ( $cookies{$cookiename} ? $cookies{$cookiename}->value() : undef ),
+ $backends{$RT::DatabaseType}
+ ? {
+ Handle => $RT::Handle->dbh,
+ LockHandle => $RT::Handle->dbh,
+ }
+ : {
+ Directory => $RT::MasonSessionDir,
+ LockDirectory => $RT::MasonSessionDir,
+ };
+};
+if ($@) {
- # morning bug avoidance attempt -- pdh 20030815
- unless ($RT::Handle->dbh && $RT::Handle->dbh->ping) {
- $RT::Handle->Connect();
- }
+ # If the session is invalid, create a new session.
eval {
- tie %session, $session_class,
- $SessionCookie || ( $cookies{$cookiename} ? $cookies{$cookiename}->value() : undef ),
- $backends{$RT::DatabaseType} ? {
+ tie %session, $session_class, undef, $backends{$RT::DatabaseType}
+ ? {
Handle => $RT::Handle->dbh,
LockHandle => $RT::Handle->dbh,
- } : {
+ }
+ : {
Directory => $RT::MasonSessionDir,
LockDirectory => $RT::MasonSessionDir,
- };
+ };
+ undef $cookies{$cookiename};
};
- if ($@) {
-
- # If the session is invalid, create a new session.
- if ( $@ =~ /Object does not/i ) {
- tie %session, $session_class, undef, $backends{$RT::DatabaseType}
- ? {
- Handle => $RT::Handle->dbh,
- LockHandle => $RT::Handle->dbh,
- }
- : {
- Directory => $RT::MasonSessionDir,
- LockDirectory => $RT::MasonSessionDir,
- };
- undef $cookies{$cookiename};
- }
- else {
- die loc("RT couldn't store your session.") . "\n"
- . loc(
-"This may mean that that the directory '[_1]' isn't writable or a database table is missing or corrupt.",
- $RT::MasonSessionDir
- )
- . "\n\n"
- . $@;
- }
- }
+}
- if ( !$cookies{$cookiename} ) {
- my $cookie = new CGI::Cookie(
- -name => $cookiename,
- -value => $session{_session_id},
- -path => '/',
- );
- $r->headers_out->{'Set-Cookie'} = $cookie->as_string;
+if ($@) {
+ die loc("RT couldn't store your session.") . "\n"
+ . loc(
+ "This may mean that that the directory '[_1]' isn't writable or a database table is missing or corrupt.",
+ $RT::MasonSessionDir
+ )
+ . "\n\n"
+ . $@;
+}
+
+if ( !$cookies{$cookiename} ) {
+ my $cookie = new CGI::Cookie(
+ -name => $cookiename,
+ -value => $session{_session_id},
+ -path => '/',
+ );
+ $r->headers_out->{'Set-Cookie'} = $cookie->as_string;
- }
+}
- return();
+return ();
</%init>
<%args>
$SessionCookie => ''
More information about the Rt-commit
mailing list