Subject: | [PATCH] deleted sessions should be marked as synch'ed |
Hello,
I'm writing a new SQL driver for CGI::Session. During this I uncovered what I think is a bug in how CGI::Session handles it's internal status. Here's the sequence in my test script that exposed it:
ok($s2->close, 'closing 2nd session');
ok($dbh->disconnect, 'disconnecting');
Also the session was closed, it's status remained 'deleted', so that after the DB connection was closed, "flush" was run again as part of DESTROY. when it tried to "remove" again because the status was still DELETED, there was a problem because the database handle was no longer there.
I think that after a session is deleted/removed, it's status should be 'synched'. Because until the session object changes again, having nothing in the database is the same as having nothing in the session object. :)
The below simple patch corrects these. "make test" continues to perform fine with the change.
--- /usr/local/lib/perl5/site_perl/5.8.0/CGI/Session.pm Fri May 2 15:10:48 2003
+++ Session.pm Fri Jul 25 12:05:08 2003
@@ -428,10 +428,10 @@
if ( $status == MODIFIED ) {
$self->store($self->id, $self->{_OPTIONS}, $self->{_DATA}) or return;
- $self->{_STATUS} = SYNCED;
} elsif ( $status == DELETED ) {
$self->remove($self->id, $self->{_OPTIONS}) or return;
}
+ $self->{_STATUS} = SYNCED;
return 1;
}