diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 0b3d903df3..557092d68c 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -2013,8 +2013,9 @@ sub account_locked { my $FailedLoginAttempts = C4::Context->preference('FailedLoginAttempts'); return 1 if $FailedLoginAttempts - and $self->login_attempts - and $self->login_attempts >= $FailedLoginAttempts; + && $FailedLoginAttempts > 0 + && $self->login_attempts + && $self->login_attempts >= $FailedLoginAttempts; return 1 if ( $self->login_attempts || 0 ) < 0; # administrative lockout return 0; } diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm index a1e83328ff..cc128faa68 100644 --- a/Koha/Patrons.pm +++ b/Koha/Patrons.pm @@ -305,10 +305,13 @@ sub search_anonymize_candidates { my $str = $parser->format_datetime($dt); $cond->{dateexpiry} = { '<=' => $str }; $cond->{anonymized} = 0; # not yet done - if ( $params->{locked} ) { - my $fails = C4::Context->preference('FailedLoginAttempts') || 0; + my $fails = C4::Context->preference('FailedLoginAttempts'); + + if ( $params->{locked} && $fails && $fails > 0 ) { # $fails should actually not be negative btw $cond->{login_attempts} = [ -and => { '!=' => undef }, { -not_in => [ 0, 1 .. $fails - 1 ] } ]; # -not_in does not like undef + } elsif ( $params->{locked} ) { + $cond->{login_attempts} = -1; } return $class->search($cond); }