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

(-)a/Koha/Item/LastPatrons.pm (-6 / +4 lines)
Lines 56-63 sub anonymise_items_last_borrower { Link Here
56
    # The default of 0 does not work due to foreign key constraints
56
    # The default of 0 does not work due to foreign key constraints
57
    # The anonymisation should not fail quietly if AnonymousPatron is not a valid entry
57
    # The anonymisation should not fail quietly if AnonymousPatron is not a valid entry
58
    # Set it to undef (NULL)
58
    # Set it to undef (NULL)
59
    my $anonymous_patron = C4::Context->preference('AnonymousPatron') || undef;
60
59
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
61
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
60
    my $nb_rows = 0;
61
    my $last_borrowers = $self->search(
62
    my $last_borrowers = $self->search(
62
        {
63
        {
63
            (
64
            (
Lines 68-78 sub anonymise_items_last_borrower { Link Here
68
            )
69
            )
69
        }
70
        }
70
    );
71
    );
71
    my $anonymous_patron = C4::Context->preference('AnonymousPatron') || undef;
72
    my $nb_rows = $last_borrowers->count; # unaffected by update
72
    while(my $last_borrower = $last_borrowers->next) {
73
    $last_borrowers->update({ borrowernumber => $anonymous_patron });
73
        $last_borrower->borrowernumber( $anonymous_patron )->store;
74
        $nb_rows++;
75
    }
76
    return $nb_rows;
74
    return $nb_rows;
77
}
75
}
78
76
(-)a/Koha/Patrons.pm (-3 lines)
Lines 31-37 use Koha::Patron; Link Here
31
use Koha::Exceptions::Patron;
31
use Koha::Exceptions::Patron;
32
use Koha::Patron::Categories;
32
use Koha::Patron::Categories;
33
use Date::Calc qw( Today Add_Delta_YMD );
33
use Date::Calc qw( Today Add_Delta_YMD );
34
use Koha::Item::LastPatrons;
35
34
36
use base qw(Koha::Objects);
35
use base qw(Koha::Objects);
37
36
Lines 140-146 sub search_patrons_to_anonymise { Link Here
140
    my ( $class, $params ) = @_;
139
    my ( $class, $params ) = @_;
141
    my $older_than_date = $params->{before};
140
    my $older_than_date = $params->{before};
142
    my $library         = $params->{library};
141
    my $library         = $params->{library};
143
144
    $older_than_date = $older_than_date ? dt_from_string($older_than_date) : dt_from_string;
142
    $older_than_date = $older_than_date ? dt_from_string($older_than_date) : dt_from_string;
145
    $library ||=
143
    $library ||=
146
      ( C4::Context->preference('IndependentBranches') && C4::Context->userenv && !C4::Context->IsSuperLibrarian() && C4::Context->userenv->{branch} )
144
      ( C4::Context->preference('IndependentBranches') && C4::Context->userenv && !C4::Context->IsSuperLibrarian() && C4::Context->userenv->{branch} )
147
- 

Return to bug 23260