From 44ac0cdce9d36d66afab9be70d02f0f490e6b63d Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 19 Mar 2021 12:03:15 +0000 Subject: [PATCH] Bug 21549: (QA follow-up) Get pref at start of run and rename variable This patch ensures the script will lock patrons if the pref is set but no other actions specified It also changes the variable name to be a bit more explicit Signed-off-by: Nick Clemens --- misc/cronjobs/cleanup_database.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl index 10ff3e6985..c4a86d1855 100755 --- a/misc/cronjobs/cleanup_database.pl +++ b/misc/cronjobs/cleanup_database.pl @@ -142,6 +142,7 @@ my $pOldReserves; my $pTransfers; my ( $pPseudoTransactions, $pPseudoTransactionsFrom, $pPseudoTransactionsTo ); my $pMessages; +my $lock_days = C4::Context->preference('LockExpiredDelay'); GetOptions( 'h|help' => \$help, @@ -222,6 +223,7 @@ unless ( $sessions || $pPseudoTransactionsFrom || $pPseudoTransactionsTo || $pMessages + || defined $lock_days && $lock_days ne q{} ) { print "You did not specify any cleanup work for the script to do.\n\n"; usage(1); @@ -401,10 +403,9 @@ if($allDebarments) { } # Lock expired patrons? -my $days = C4::Context->preference('LockExpiredDelay'); -if( defined $days && $days ne q{} ) { +if( defined $lock_days && $lock_days ne q{} ) { say "Start locking expired patrons" if $verbose; - my $expired_patrons = Koha::Patrons->filter_by_dateexpiry({ days => $days })->search({ login_attempts => { '!=' => -1 } }); + my $expired_patrons = Koha::Patrons->filter_by_dateexpiry({ days => $lock_days })->search({ login_attempts => { '!=' => -1 } }); my $count = $expired_patrons->count; $expired_patrons->lock({ remove => 1 }) if $confirm; if( $verbose ) { -- 2.11.0