From a9d7aa85186ddd7f0488c89337544d56d09fcccb Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 29 Nov 2019 09:45:48 +0000 Subject: [PATCH] Bug 24114: (QA follow-up) Fix counts for lock, anonymize and delete Since these operations impact on the resultset, the counts should be saved before. Signed-off-by: Marcel de Rooy Signed-off-by: Bouzid Fergani Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson (cherry picked from commit 9b0ba1c096ed72bd867792a11de59a825355e6dc) Signed-off-by: Lucas Gass --- misc/cronjobs/cleanup_database.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl index 964214122b..9d397b5018 100755 --- a/misc/cronjobs/cleanup_database.pl +++ b/misc/cronjobs/cleanup_database.pl @@ -307,22 +307,25 @@ if($allDebarments) { # Handle unsubscribe requests from GDPR consent form, depends on UnsubscribeReflectionDelay preference my $unsubscribed_patrons = Koha::Patrons->search_unsubscribed; +$count = $unsubscribed_patrons->count; $unsubscribed_patrons->lock( { expire => 1, remove => 1 } ); -say sprintf "Locked %d patrons", $unsubscribed_patrons->count if $verbose; +say sprintf "Locked %d patrons", $count if $verbose; # Anonymize patron data, depending on PatronAnonymizeDelay my $anonymize_candidates = Koha::Patrons->search_anonymize_candidates( { locked => 1 } ); +$count = $anonymize_candidates->count; $anonymize_candidates->anonymize; -say sprintf "Anonymized %s patrons", $anonymize_candidates->count if $verbose; +say sprintf "Anonymized %s patrons", $count if $verbose; # Remove patron data, depending on PatronRemovalDelay (will raise an exception if problem encountered my $anonymized_patrons = Koha::Patrons->search_anonymized; +$count = $anonymized_patrons->count; $anonymized_patrons->delete( { move => 1 } ); if ($@) { warn $@; } elsif ($verbose) { - say sprintf "Deleted %d patrons", $anonymized_patrons->count; + say sprintf "Deleted %d patrons", $count; } if( $pExpSelfReg ) { -- 2.39.5