Fix some missing "lazy" (#1545)

This commit is contained in:
Xavier Guimard 2018-11-16 17:30:57 +01:00
parent 69cdd66444
commit 642e98e180
7 changed files with 18 additions and 9 deletions

View File

@ -11,8 +11,9 @@ has p => ( is => 'rw', weak_ref => 1 );
# Lemonldap::NG configuration hash ref
has conf => ( is => 'rw', weak_ref => 1 );
has logger => ( is => 'rw', default => sub { $_[0]->{p}->logger } );
has userLogger => ( is => 'rw', default => sub { $_[0]->{p}->userLogger } );
has logger => ( is => 'rw', lazy => 1, default => sub { $_[0]->{p}->logger } );
has userLogger =>
( is => 'rw', lazy => 1, default => sub { $_[0]->{p}->userLogger } );
sub error {
my $self = shift;

View File

@ -22,6 +22,7 @@ sub import {
has dbiTable => (
is => 'ro',
lazy => 1,
default => sub { $_[0]->{table} || 'notifications' }
);
@ -32,6 +33,7 @@ has dbiChain => (
has dbiUser => (
is => 'ro',
lazy => 1,
default => sub {
$_[0]->{p}->logger->warn('Warning: "dbiUser" parameter is not set');
return '';
@ -64,7 +66,9 @@ sub get {
my ( $self, $uid, $ref ) = @_;
return () unless ($uid);
$self->_execute(
"SELECT * FROM $self->{dbiTable} WHERE done IS NULL AND uid=?"
"SELECT * FROM "
. $self->dbiTable
. " WHERE done IS NULL AND uid=?"
. ( $ref ? " AND ref=?" : '' )
. "ORDER BY date",
$uid,

View File

@ -38,6 +38,7 @@ has ldapConfBase => (
has ldapBindDN => (
is => 'ro',
lazy => 1,
default => sub {
$_[0]->p->logger->warn('Warning: "ldapBindDN" parameter is not set');
return '';

View File

@ -34,6 +34,7 @@ has sfReq => ( is => 'rw' );
has ott => (
is => 'rw',
lazy => 1,
default => sub {
my $ott =
$_[0]->{p}->loadModule('Lemonldap::NG::Portal::Lib::OneTimeToken');

View File

@ -21,7 +21,7 @@ has wrapUserLogger => (
lazy => 1,
default => sub {
Lemonldap::NG::Portal::Lib::Combination::UserLogger->new(
$_[0]->{userLogger} );
$_[0]->userLogger );
}
);

View File

@ -18,6 +18,7 @@ extends 'Lemonldap::NG::Portal::Main::Plugin';
has ott => (
is => 'rw',
lazy => 1,
default => sub {
my $ott =
$_[0]->{p}->loadModule('Lemonldap::NG::Portal::Lib::OneTimeToken');

View File

@ -498,6 +498,7 @@ has p => ( is => 'rw' );
has ini => (
is => 'rw',
lazy => 1,
default => sub { $defaultIni; },
trigger => sub {
my ( $self, $ini ) = @_;
@ -626,7 +627,7 @@ sub _get {
: ()
),
'REQUEST_METHOD' => $args{method} || 'GET',
'REQUEST_URI' => $path . ( $args{query} ? "?$args{query}" : '' ),
'REQUEST_URI' => $path . ( $args{query} ? "?$args{query}" : '' ),
( $args{query} ? ( QUERY_STRING => $args{query} ) : () ),
'SCRIPT_NAME' => '',
'SERVER_NAME' => 'auth.example.com',
@ -678,10 +679,10 @@ sub _post {
: ()
),
'REQUEST_METHOD' => $args{method} || 'POST',
'REQUEST_URI' => $path . ( $args{query} ? "?$args{query}" : '' ),
'SCRIPT_NAME' => '',
'SERVER_NAME' => 'auth.example.com',
'SERVER_PORT' => '80',
'REQUEST_URI' => $path . ( $args{query} ? "?$args{query}" : '' ),
'SCRIPT_NAME' => '',
'SERVER_NAME' => 'auth.example.com',
'SERVER_PORT' => '80',
'SERVER_PROTOCOL' => 'HTTP/1.1',
( $args{custom} ? %{ $args{custom} } : () ),
'psgix.input.buffered' => 0,