From bdaa3ab861b10e81bbb89f28a097d20ca4e98de9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 24 Jun 2020 16:11:21 +0200 Subject: [PATCH] Bug 24153: Make sure $count will not be reused for another purpose The $count variable should be defined per block and set to 0 to avoid confusion. --- misc/cronjobs/cleanup_database.pl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl index 4bc3a07a1f..24be963c8e 100755 --- a/misc/cronjobs/cleanup_database.pl +++ b/misc/cronjobs/cleanup_database.pl @@ -229,7 +229,6 @@ cronlogaction() unless $confirm; my $dbh = C4::Context->dbh(); my $sth; my $sth2; -my $count; if ( $sessions && !$sess_days ) { if ($verbose) { @@ -254,7 +253,7 @@ elsif ( $sessions && $sess_days > 0 ) { } if ($zebraqueue_days) { - $count = 0; + my $count = 0; print "Zebraqueue purge triggered for $zebraqueue_days days.\n" if $verbose; $sth = $dbh->prepare( q{ @@ -280,6 +279,7 @@ if ($zebraqueue_days) { } if ($mail) { + my $count = 0; print "Mail queue purge triggered for $mail days.\n" if $verbose; $count = 0; $sth = $dbh->prepare( @@ -362,7 +362,7 @@ if ($pListShareInvites) { if ($pDebarments) { print "Expired patrons restrictions purge triggered for $pDebarments days.\n" if $verbose; - $count = PurgeDebarments($pDebarments, $confirm); + my $count = PurgeDebarments($pDebarments, $confirm); if ( $verbose ) { say $confirm ? "$count restrictions were deleted." : "$count restrictions would have been deleted"; say "Done with restrictions purge."; @@ -371,7 +371,7 @@ if ($pDebarments) { if($allDebarments) { print "All expired patrons restrictions purge triggered.\n" if $verbose; - $count = PurgeDebarments(0, $confirm); + my $count = PurgeDebarments(0, $confirm); if ( $verbose ) { say $confirm ? "$count restrictions were deleted." : "$count restrictions would have been deleted"; say "Done with all restrictions purge."; @@ -380,7 +380,7 @@ if($allDebarments) { # Handle unsubscribe requests from GDPR consent form, depends on UnsubscribeReflectionDelay preference my $unsubscribed_patrons = Koha::Patrons->search_unsubscribed; -$count = $unsubscribed_patrons->count; +my $count = $unsubscribed_patrons->count; $unsubscribed_patrons->lock( { expire => 1, remove => 1 } ) if $confirm; say $confirm ? sprintf("Locked %d patrons", $count) : sprintf("%d patrons would have been locked", $count) if $verbose; @@ -588,7 +588,7 @@ sub RemoveOldSessions { $sth->execute or die $dbh->errstr; $sth->bind_columns( \$id, \$a_session ); $sth2 = $dbh->prepare(q{ DELETE FROM sessions WHERE id=? }); - $count = 0; + my $count = 0; while ( $sth->fetch ) { $lasttime = 0; @@ -650,7 +650,7 @@ sub PurgeZ3950 { sub PurgeDebarments { require Koha::Patron::Debarments; my ( $days, $doit ) = @_; - $count = 0; + my $count = 0; $sth = $dbh->prepare( q{ SELECT borrower_debarment_id -- 2.20.1