View | Details | Raw Unified | Return to bug 24114
Collapse All | Expand All

(-)a/Koha/Patrons.pm (-1 / +1 lines)
Lines 286-292 sub search_anonymize_candidates { Link Here
286
    $cond->{dateexpiry} = { '<=' => $str };
286
    $cond->{dateexpiry} = { '<=' => $str };
287
    $cond->{anonymized} = 0; # not yet done
287
    $cond->{anonymized} = 0; # not yet done
288
    if( $params->{locked} ) {
288
    if( $params->{locked} ) {
289
        my $fails = C4::Context->preference('FailedLoginAttempts');
289
        my $fails = C4::Context->preference('FailedLoginAttempts') || 0;
290
        $cond->{login_attempts} = [ -and => { '!=' => undef }, { -not_in => [0, 1..$fails-1 ] } ]; # -not_in does not like undef
290
        $cond->{login_attempts} = [ -and => { '!=' => undef }, { -not_in => [0, 1..$fails-1 ] } ]; # -not_in does not like undef
291
    }
291
    }
292
    return $class->search( $cond );
292
    return $class->search( $cond );
(-)a/t/db_dependent/Koha/Patrons.t (-2 / +10 lines)
Lines 1837-1843 subtest 'search_unsubscribed' => sub { Link Here
1837
};
1837
};
1838
1838
1839
subtest 'search_anonymize_candidates' => sub {
1839
subtest 'search_anonymize_candidates' => sub {
1840
    plan tests => 5;
1840
    plan tests => 7;
1841
    my $patron1 = $builder->build_object({ class => 'Koha::Patrons' });
1841
    my $patron1 = $builder->build_object({ class => 'Koha::Patrons' });
1842
    my $patron2 = $builder->build_object({ class => 'Koha::Patrons' });
1842
    my $patron2 = $builder->build_object({ class => 'Koha::Patrons' });
1843
    $patron1->anonymized(0);
1843
    $patron1->anonymized(0);
Lines 1879-1884 subtest 'search_anonymize_candidates' => sub { Link Here
1879
    $patron1->login_attempts(3)->store;
1879
    $patron1->login_attempts(3)->store;
1880
    is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
1880
    is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
1881
        $cnt+1, 'Locked flag' );
1881
        $cnt+1, 'Locked flag' );
1882
1883
    t::lib::Mocks::mock_preference( 'FailedLoginAttempts', q{} );
1884
    # Patron 1 still on 3 == locked
1885
    is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
1886
        $cnt+1, 'Still expect same number for FailedLoginAttempts empty' );
1887
    $patron1->login_attempts(0)->store;
1888
    # Patron 1 unlocked
1889
    is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
1890
        $cnt, 'Patron 1 unlocked' );
1882
};
1891
};
1883
1892
1884
subtest 'search_anonymized' => sub {
1893
subtest 'search_anonymized' => sub {
1885
- 

Return to bug 24114