From 26080309e71fecb3ef2022bf6f0b1e4bef7b48dd Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 9 Nov 2017 10:34:08 -0300 Subject: [PATCH] Bug 19599: Simplify the query --- Koha/Patrons.pm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm index 263cec72a4..e833a1d963 100644 --- a/Koha/Patrons.pm +++ b/Koha/Patrons.pm @@ -168,9 +168,10 @@ sub anonymise_issue_history { # The anonymisation should not fail quietly if AnonymousPatron is not a valid entry # Set it to undef (NULL) my $dtf = Koha::Database->new->schema->storage->datetime_parser; - my $old_issues_to_anonymise = $self->search_related( - 'old_issues', + my $anonymous_patron = C4::Context->preference('AnonymousPatron') || undef; + Koha::Old::Checkouts->search( { + borrowernumber => { in => [ $self->get_column('borrowernumber') ] }, ( $older_than_date ? ( returndate => @@ -178,9 +179,7 @@ sub anonymise_issue_history { : () ) } - ); - my $anonymous_patron = C4::Context->preference('AnonymousPatron') || undef; - $old_issues_to_anonymise->update( { 'old_issues.borrowernumber' => $anonymous_patron } ); + )->update( { 'old_issues.borrowernumber' => $anonymous_patron } ); } =head3 type -- 2.11.0