[Rt-commit] r4028 - in rt/branches/3.7-EXPERIMENTAL: . etc html/Elements

ruz at bestpractical.com ruz at bestpractical.com
Fri Nov 4 20:56:12 EST 2005


Author: ruz
Date: Fri Nov  4 20:56:12 2005
New Revision: 4028

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/etc/schema.mysql
   rt/branches/3.7-EXPERIMENTAL/html/Elements/SetupSessionCookie
Log:
 r1171 at cubic-pc:  cubic | 2005-11-05 04:57:11 +0300
  r1167 at cubic-pc:  cubic | 2005-11-04 04:34:16 +0300
  * setup session cookies refactor
 


Modified: rt/branches/3.7-EXPERIMENTAL/etc/schema.mysql
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/etc/schema.mysql	(original)
+++ rt/branches/3.7-EXPERIMENTAL/etc/schema.mysql	Fri Nov  4 20:56:12 2005
@@ -9,7 +9,7 @@
   Filename varchar(255) NULL  ,
   ContentType varchar(80) NULL  ,
   ContentEncoding varchar(80) NULL  ,
-  Content LONGTEXT NULL  ,
+  Content LONGBLOB NULL  ,
   Headers LONGTEXT NULL  ,
   Creator integer NOT NULL DEFAULT 0  ,
   Created DATETIME NULL  ,
@@ -46,8 +46,8 @@
 
 CREATE TABLE Links (
   id INTEGER NOT NULL  AUTO_INCREMENT,
-  Base varchar(240) NULL  ,
-  Target varchar(240) NULL  ,
+  Base varchar(240) CHARACTER SET latin1 NULL  ,
+  Target varchar(240) CHARACTER SET latin1 NULL  ,
   Type varchar(20) NOT NULL  ,
   LocalTarget integer NOT NULL DEFAULT 0  ,
   LocalBase integer NOT NULL DEFAULT 0  ,
@@ -455,8 +455,8 @@
 # We should have a reaper script somewhere.
 
 CREATE TABLE sessions (
-    id char(32) NOT NULL,
-    a_session LONGTEXT,
+    id char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
+    a_session LONGBLOB,
     LastUpdated TIMESTAMP,
     PRIMARY KEY (id)
 );

Modified: rt/branches/3.7-EXPERIMENTAL/html/Elements/SetupSessionCookie
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Elements/SetupSessionCookie	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Elements/SetupSessionCookie	Fri Nov  4 20:56:12 2005
@@ -43,72 +43,61 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
-<%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'};
+<%ONCE>
 my %backends = (
     mysql	=> 'Apache::Session::MySQL',
     Pg		=> 'Apache::Session::Postgres',
 #    Oracle	=> 'Apache::Session::Oracle',
-) unless $RT::WebSessionClass;
+);
+</%ONCE>
+<%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'};
+$SessionCookie ||= ( $cookies{$cookiename} ? $cookies{$cookiename}->value() : undef ),
+
 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();
+my $session_attrs = $backends{$RT::DatabaseType} ? {
+    Handle     => $RT::Handle->dbh,
+    LockHandle => $RT::Handle->dbh,
+} : {
+    Directory     => $RT::MasonSessionDir,
+    LockDirectory => $RT::MasonSessionDir,
+};
+
+eval {
+    tie %session, $session_class, $SessionCookie, $session_attrs;
+};
+if ($@) {
+
+    # If the session is invalid, create a new session.
+    if ( $@ =~ /Object does not/i ) {
+        tie %session, $session_class, undef, $session_attrs;
+        undef $cookies{$cookiename};
     }
-    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 ($@) {
-
-        # 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"
-              . $@;
-        }
+    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;
-
-    } 
-
-    return();
-</%init>
-<%args>
+if ( !$cookies{$cookiename} ) {
+    my $cookie = new CGI::Cookie(
+        -name  => $cookiename,
+        -value => $session{_session_id},
+        -path  => '/',
+    );
+    $r->headers_out->{'Set-Cookie'} = $cookie->as_string;
+} 
+
+return();
+</%INIT>
+<%ARGS>
 $SessionCookie => ''
-</%args>
+</%ARGS>


More information about the Rt-commit mailing list