From efbd416aa67c67e4905d4c598ae4e5719d916d94 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 3 Jan 2020 12:35:33 +0000 Subject: [PATCH] Bug 23260: [ALTERNATIVE] Inline code to anonymise_issue_history This alternative patch reduces the complexity of the change by simply updateing the existing anonymise_issue_history method to include anonymisation of the items_last_borrowers table. --- Koha/Patrons.pm | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm index f4ca8456a6..f0a9ce4d5a 100644 --- a/Koha/Patrons.pm +++ b/Koha/Patrons.pm @@ -165,9 +165,11 @@ sub search_patrons_to_anonymise { Koha::Patrons->search->anonymise_issue_history( { [ before => $older_than_date ] } ); -Anonymise issue history (old_issues) for all patrons older than the given date (optional). +Anonymise issue history (old_issues and items_last_borrowers) for all issues older +than the given date (optional). + To make sure all the conditions are met, the caller has the responsibility to -call search_patrons_to_anonymise to filter the Koha::Patrons set +call search_patrons_to_anonymise to filter the Koha::Patrons set. =cut @@ -194,8 +196,22 @@ sub anonymise_issue_history { ) } ); + + my $last_borrowers_to_anonymise = + $patron->_resultset->items_last_borrowers->search( + { + ( + $older_than_date + ? ( created_on => + { '<' => $dtf->format_datetime($older_than_date) } ) + : () + ) + } + ); + my $anonymous_patron = C4::Context->preference('AnonymousPatron') || undef; $nb_rows += $old_issues_to_anonymise->update( { 'old_issues.borrowernumber' => $anonymous_patron } ); + $nb_rows += $last_borrowers_to_anonymise->update( { 'items_last_borrowers.borrowernumber' => $anonymous_patron } ); } return $nb_rows; } -- 2.20.1