LEMONLDAP::NG : * Support for Apache::Session::PHP (for Manager/Session and purgeCentralCache)
* better cache control for Common::CGI.pm::header_public() * bug with the manager introduced previously
This commit is contained in:
parent
5bbe35cedc
commit
789a39df97
|
@ -13,7 +13,6 @@ BEGIN {
|
|||
my $args = shift;
|
||||
my $data = shift;
|
||||
|
||||
# TODO : replace die by abort
|
||||
my $dbh =
|
||||
DBI->connect( $args->{DataSource}, $args->{UserName},
|
||||
$args->{Password} )
|
||||
|
@ -24,7 +23,7 @@ BEGIN {
|
|||
while ( my @row = $sth->fetchrow_array ) {
|
||||
if ( ref($data) eq 'CODE' ) {
|
||||
my $tmp = &$data( thaw( $row[1] ), $row[0] );
|
||||
$res{ $row[0] }->{$_} = $tmp if ( defined($tmp) );
|
||||
$res{ $row[0] } = $tmp if ( defined($tmp) );
|
||||
}
|
||||
elsif ($data) {
|
||||
$data = [$data] unless ( ref($data) );
|
||||
|
@ -53,7 +52,6 @@ BEGIN {
|
|||
my $data = shift;
|
||||
$args->{Directory} ||= '/tmp';
|
||||
|
||||
# TODO : replace die by abort
|
||||
unless ( opendir DIR, $args->{Directory} ) {
|
||||
die "Cannot open directory $args->{Directory}\n";
|
||||
}
|
||||
|
@ -66,7 +64,7 @@ BEGIN {
|
|||
open F, "$args->{Directory}/$f";
|
||||
my $row = join '', <F>;
|
||||
if ( ref($data) eq 'CODE' ) {
|
||||
$res{$f}->{$_} = &$data( thaw($row), $f );
|
||||
$res{$f} = &$data( thaw($row), $f );
|
||||
}
|
||||
elsif ($data) {
|
||||
$data = [$data] unless ( ref($data) );
|
||||
|
@ -80,19 +78,69 @@ BEGIN {
|
|||
return \%res;
|
||||
}
|
||||
|
||||
sub Apache::Session::PHP::get_key_from_all_sessions {
|
||||
require Apache::Session::Serialize::PHP;
|
||||
my $class = shift;
|
||||
my $args = shift;
|
||||
|
||||
my $directory = $args->{SavePath} || '/tmp';
|
||||
unless ( opendir DIR, $args->{SavePath} ) {
|
||||
die "Cannot open directory $args->{SavePath}\n";
|
||||
}
|
||||
my @t =
|
||||
grep { -f "$args->{SavePath}/$_" and /^sess_[A-Za-z0-9@\-]+$/ }
|
||||
readdir(DIR);
|
||||
closedir DIR;
|
||||
my %res;
|
||||
for my $f (@t) {
|
||||
open F, "$args->{SavePath}/$f";
|
||||
my $row = join '', <F>;
|
||||
if ( ref($data) eq 'CODE' ) {
|
||||
$res{$f} = &$data( Apache::Session::Serialize::PHP::unserialize($row), $f );
|
||||
}
|
||||
elsif ($data) {
|
||||
$data = [$data] unless ( ref($data) );
|
||||
my $tmp = Apache::Session::Serialize::PHP::unserialize($row);
|
||||
$res{$f}->{$_} = $tmp->{$_} foreach (@$data);
|
||||
}
|
||||
else {
|
||||
$res{$f} = Apache::Session::Serialize::PHP::unserialize($row);
|
||||
}
|
||||
}
|
||||
return \%res;
|
||||
}
|
||||
|
||||
sub Apache::Session::DB_File::get_key_from_all_sessions {
|
||||
my $class = shift;
|
||||
my $args = shift;
|
||||
|
||||
if ( !tied %{ $class->{dbm} } ) {
|
||||
my $rv = tie %{ $class->{dbm} }, 'DB_File', $args->{FileName};
|
||||
|
||||
# TODO : replace die by abort
|
||||
if ( !$rv ) {
|
||||
die "Could not open dbm file " . $args->{FileName} . ": $!";
|
||||
}
|
||||
}
|
||||
return keys( %{ $class->{dbm} } );
|
||||
|
||||
my %res;
|
||||
foreach my $k ( keys %{ $class->{dbm} } ) {
|
||||
if ( ref($data) eq 'CODE' ) {
|
||||
$res{$k} = &$data( thaw( $class->{dbm}->{$k} ), $k );
|
||||
}
|
||||
elsif ($data) {
|
||||
$data = [$data] unless ( ref($data) );
|
||||
my $tmp = thaw( $class->{dbm}->{$k} );
|
||||
$res{$k}->{$_} = $tmp->{$_} foreach (@$data);
|
||||
}
|
||||
else {
|
||||
$res{$k} = thaw( $class->{dbm}->{$k} );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub Apache::Session::Memcached::get_key_from_all_sessions {
|
||||
|
||||
# TODO
|
||||
die ('Apache::Session::Memcached is not supported by Lemonldap::NG');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ sub header_public {
|
|||
my $cm = $2;
|
||||
|
||||
# TODO: Remove TODO_ for stable releases
|
||||
if ( my $ref = $ENV{TODO_HTTP_IF_MODIFIED_SINCE} ) {
|
||||
if ( my $ref = $ENV{HTTP_IF_MODIFIED_SINCE} ) {
|
||||
my %month = (
|
||||
jan => 0,
|
||||
feb => 1,
|
||||
|
@ -61,7 +61,7 @@ sub header_public {
|
|||
}
|
||||
return $self->SUPER::header(
|
||||
'-Last-Modified' => $hd,
|
||||
'-Cache-Control' => 'public; must-revalidate',
|
||||
'-Cache-Control' => 'public; must-revalidate; max-age=1800',
|
||||
@_
|
||||
);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ use LWP::UserAgent;
|
|||
use Safe;
|
||||
use MIME::Base64;
|
||||
|
||||
use base qw(CGI);
|
||||
use base qw(Lemonldap::NG::Common::CGI);
|
||||
our @ISA;
|
||||
|
||||
our $VERSION = '0.87';
|
||||
|
|
Loading…
Reference in New Issue
Block a user