Bug 24114: (follow-up) Resolve warning on non-numeric subtraction
Argument "" isn't numeric in subtraction (-) at /usr/share/koha/Koha/Patrons.pm line 290.
Coming from an empty or undefined FailedLoginAttempts.
Test plan:
Verify that Koha/Patrons.t still passes.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Bouzid Fergani <bouzid.fergani@inlibro.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
(cherry picked from commit c242f86677)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
7399a8de94
commit
d0623804eb
|
|
@ -296,7 +296,7 @@ sub search_anonymize_candidates {
|
|||
$cond->{dateexpiry} = { '<=' => $str };
|
||||
$cond->{anonymized} = 0; # not yet done
|
||||
if( $params->{locked} ) {
|
||||
my $fails = C4::Context->preference('FailedLoginAttempts');
|
||||
my $fails = C4::Context->preference('FailedLoginAttempts') || 0;
|
||||
$cond->{login_attempts} = [ -and => { '!=' => undef }, { -not_in => [0, 1..$fails-1 ] } ]; # -not_in does not like undef
|
||||
}
|
||||
return $class->search( $cond );
|
||||
|
|
|
|||
|
|
@ -1701,7 +1701,7 @@ subtest 'search_unsubscribed' => sub {
|
|||
};
|
||||
|
||||
subtest 'search_anonymize_candidates' => sub {
|
||||
plan tests => 5;
|
||||
plan tests => 7;
|
||||
my $patron1 = $builder->build_object({ class => 'Koha::Patrons' });
|
||||
my $patron2 = $builder->build_object({ class => 'Koha::Patrons' });
|
||||
$patron1->anonymized(0);
|
||||
|
|
@ -1743,6 +1743,15 @@ subtest 'search_anonymize_candidates' => sub {
|
|||
$patron1->login_attempts(3)->store;
|
||||
is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
|
||||
$cnt+1, 'Locked flag' );
|
||||
|
||||
t::lib::Mocks::mock_preference( 'FailedLoginAttempts', q{} );
|
||||
# Patron 1 still on 3 == locked
|
||||
is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
|
||||
$cnt+1, 'Still expect same number for FailedLoginAttempts empty' );
|
||||
$patron1->login_attempts(0)->store;
|
||||
# Patron 1 unlocked
|
||||
is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
|
||||
$cnt, 'Patron 1 unlocked' );
|
||||
};
|
||||
|
||||
subtest 'search_anonymized' => sub {
|
||||
|
|
|
|||
Loading…
Reference in New Issue