Force deletion of corrupted sessions in DBI and LDAP backends
On an installation, several sessions where corrupted in a DBI backend, and the purge script could not delete them.
Here is a simple code to add in purgeCentralCache script to delete sessions directly in the table:
# Force deletion of corrupted sessions for DBI backend
if ( $options->{backend} =~ /^Apache::Session::(?:Browseable::)?(MySQL|Postgres|DBI|Oracle|Informix|MySQLJSON|PgHstore|PgJSON|SQLLite|Sybase)$/i
and $force )
{
my $dbi = DBI->connect_cached($options->{DataSource}, $options->{UserName}, $options->{Password});
my $table = $options->{TableName} || "sessions";
my $req = $dbi->prepare("DELETE from $table WHERE id=?");
foreach (@errors) {
my $id = $_;
my $res = $req->execute($id);
unless ($res == 1) {
print STDERR "Fail to delete session $id with force\n";
}
else {
print STDERR "Session $id removed with force\n";
$nb_error--;
}
}
}
We could do quite the same for LDAP