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

ruz at bestpractical.com ruz at bestpractical.com
Sat Nov 5 05:02:50 EST 2005


Author: ruz
Date: Sat Nov  5 05:02:50 2005
New Revision: 4032

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/html/Elements/SetupSessionCookie
Log:
 r1182 at cubic-pc:  cubic | 2005-11-05 13:06:01 +0300
  r1181 at cubic-pc:  cubic | 2005-11-05 13:05:46 +0300
  * instead of using LastUpdated and stat on the session files store
    '_session_last_updated' in session data, more simple code and
    more effective.
 


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	Sat Nov  5 05:02:50 2005
@@ -87,28 +87,16 @@
     }
 }
 
-if ( int( $RT::AutoLogoff || 0 ) ) {
-    my $last_update = new RT::Date( RT::SystemUser );
-    if( $session_class eq 'Apache::Session::File' ) {
-        require File::Spec;
-        my $file = File::Spec->cat($RT::MasonSessionDir, $session{'_session_id'});
-        $last_update->Set( Format => 'unix', Value => (stat $file)[9] );
-    } else {
-        my $sth = $RT::Handle->SimpleQuery("SELECT LastUpdated FROM sessions WHERE id = ?", $session{'_session_id'});
-        if( $sth ) {
-            # XXX: use datemanip format to force server's timezone because LastUpdated
-            # column is TIMESTAMP and mysql use local timezone for its values
-            # it should be changed when $date->Set would be able to handle timezones
-            $last_update->Set( Format => 'datemanip', Value => ($sth->fetchrow_array)[0] );
-        }
-    }
+if ( int $RT::AutoLogoff ) {
+    my $now = int(time/60);
+    my $last_update = $session{'_session_last_update'} || 0;
 
-    if ( -$last_update->Diff( time ) > $RT::AutoLogoff * 60 ) {
-        %session = ();
+    if ( $last_update && ($now - $last_update - $RT::AutoLogoff) > 0 ) {
+        %session = (_session_id => $session{'_session_id'});
     }
 
     # save session on each request when AutoLogoff is turned on
-    $session{'i'}++;
+    $session{'_session_last_update'} = $now if $now != $last_update;
 }
 
 if ( !$cookies{$cookiename} ) {


More information about the Rt-commit mailing list