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

(-)a/Koha/Patrons.pm (-1 / +1 lines)
Lines 290-296 sub search_anonymize_candidates { Link Here
290
    $cond->{dateexpiry} = { '<=' => $str };
290
    $cond->{dateexpiry} = { '<=' => $str };
291
    $cond->{anonymized} = 0; # not yet done
291
    $cond->{anonymized} = 0; # not yet done
292
    if( $params->{locked} ) {
292
    if( $params->{locked} ) {
293
        my $fails = C4::Context->preference('FailedLoginAttempts');
293
        my $fails = C4::Context->preference('FailedLoginAttempts') || 0;
294
        $cond->{login_attempts} = [ -and => { '!=' => undef }, { -not_in => [0, 1..$fails-1 ] } ]; # -not_in does not like undef
294
        $cond->{login_attempts} = [ -and => { '!=' => undef }, { -not_in => [0, 1..$fails-1 ] } ]; # -not_in does not like undef
295
    }
295
    }
296
    return $class->search( $cond );
296
    return $class->search( $cond );
(-)a/t/db_dependent/Koha/Patrons.t (-2 / +10 lines)
Lines 1845-1851 subtest 'search_unsubscribed' => sub { Link Here
1845
};
1845
};
1846
1846
1847
subtest 'search_anonymize_candidates' => sub {
1847
subtest 'search_anonymize_candidates' => sub {
1848
    plan tests => 5;
1848
    plan tests => 7;
1849
    my $patron1 = $builder->build_object({ class => 'Koha::Patrons' });
1849
    my $patron1 = $builder->build_object({ class => 'Koha::Patrons' });
1850
    my $patron2 = $builder->build_object({ class => 'Koha::Patrons' });
1850
    my $patron2 = $builder->build_object({ class => 'Koha::Patrons' });
1851
    $patron1->anonymized(0);
1851
    $patron1->anonymized(0);
Lines 1887-1892 subtest 'search_anonymize_candidates' => sub { Link Here
1887
    $patron1->login_attempts(3)->store;
1887
    $patron1->login_attempts(3)->store;
1888
    is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
1888
    is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
1889
        $cnt+1, 'Locked flag' );
1889
        $cnt+1, 'Locked flag' );
1890
1891
    t::lib::Mocks::mock_preference( 'FailedLoginAttempts', q{} );
1892
    # Patron 1 still on 3 == locked
1893
    is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
1894
        $cnt+1, 'Still expect same number for FailedLoginAttempts empty' );
1895
    $patron1->login_attempts(0)->store;
1896
    # Patron 1 unlocked
1897
    is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
1898
        $cnt, 'Patron 1 unlocked' );
1890
};
1899
};
1891
1900
1892
subtest 'search_anonymized' => sub {
1901
subtest 'search_anonymized' => sub {
1893
- 

Return to bug 24114