From 5c1b84ca728feddfcc8a18d5d77e567fb279a2b2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 1 Nov 2018 13:22:27 -0300 Subject: [PATCH] Bug 21723: Do no retrieve already anonymised entries --- Koha/Patrons.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm index dedf4c4a65..5f8b2c8bcb 100644 --- a/Koha/Patrons.pm +++ b/Koha/Patrons.pm @@ -154,11 +154,13 @@ sub search_patrons_to_anonymise { ( C4::Context->preference('IndependentBranches') && C4::Context->userenv && !C4::Context->IsSuperLibrarian() && C4::Context->userenv->{branch} ) ? C4::Context->userenv->{branch} : undef; + my $anonymous_patron = C4::Context->preference('AnonymousPatron') || undef; my $dtf = Koha::Database->new->schema->storage->datetime_parser; my $rs = $class->_resultset->search( - { returndate => { '<' => $dtf->format_datetime($older_than_date), }, - 'old_issues.borrowernumber' => { 'not' => undef }, + { + returndate => { '<' => $dtf->format_datetime($older_than_date), }, + 'old_issues.borrowernumber' => { 'not' => [ undef, ( $anonymous_patron ? $anonymous_patron : () )]}, privacy => { '<>' => 0 }, # Keep forever ( $library ? ( 'old_issues.branchcode' => $library ) : () ), }, -- 2.11.0