From c913d82091c779c87a1bed9f15c6eb17c874b3c9 Mon Sep 17 00:00:00 2001
From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Date: Tue, 7 Sep 2021 14:14:44 +0000
Subject: [PATCH] Bug 28962: Add del-unv-selfreg to crontab
We also add a test by inserting a simulated borrower modification
record in the same table which should not be deleted.
NOTE: This patch fixes the del-unv-selfreg parameter in the
cleanup db script. It did not even do what it promised :)
Test plan:
Verify if the crontab change is correct.
Run t/db_dependent/Members.t
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
---
debian/koha-common.cron.daily | 2 +-
misc/cronjobs/cleanup_database.pl | 2 +-
misc/cronjobs/crontab.example | 2 +-
t/db_dependent/Members.t | 3 +++
4 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/debian/koha-common.cron.daily b/debian/koha-common.cron.daily
index baf956fe4c3..c24f9c6043d 100644
--- a/debian/koha-common.cron.daily
+++ b/debian/koha-common.cron.daily
@@ -23,7 +23,7 @@ koha-foreach --chdir --enabled --email /usr/share/koha/bin/cronjobs/advance_noti
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/serialsUpdate.pl -c
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/membership_expiry.pl -c
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/cancel_expired_holds.pl >/dev/null 2>&1
-koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/cleanup_database.pl --confirm --sessions --zebraqueue 10 --list-invites --temp-uploads
+koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/cleanup_database.pl --confirm --sessions --zebraqueue 10 --list-invites --temp-uploads --del-unv-selfreg 14
koha-foreach --chdir --enabled --noemail /usr/share/koha/bin/cronjobs/cleanup_database.pl --confirm --mail
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/auto_unsuspend_holds.pl > /dev/null 2>&1
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/merge_authorities.pl -b
diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl
index 7d22d5d5d13..56b7a7d7c4f 100755
--- a/misc/cronjobs/cleanup_database.pl
+++ b/misc/cronjobs/cleanup_database.pl
@@ -170,7 +170,7 @@ GetOptions(
'restrictions:i' => \$pDebarments,
'all-restrictions' => \$allDebarments,
'del-exp-selfreg' => \$pExpSelfReg,
- 'del-unv-selfreg' => \$pUnvSelfReg,
+ 'del-unv-selfreg:i' => \$pUnvSelfReg,
'unique-holidays:i' => \$special_holidays_days,
'temp-uploads' => \$temp_uploads,
'temp-uploads-days:i' => \$temp_uploads_days,
diff --git a/misc/cronjobs/crontab.example b/misc/cronjobs/crontab.example
index 9d16403993b..9bcb01700a3 100644
--- a/misc/cronjobs/crontab.example
+++ b/misc/cronjobs/crontab.example
@@ -84,7 +84,7 @@ KOHA_CRON_PATH = /usr/share/koha/bin/cronjobs
*/10 * * * * __KOHA_USER__ $KOHA_CRON_PATH/../migration_tools/rebuild_zebra.pl -b -a -z >/dev/null
# clean up databases nightly. Be sure not to run this with --sessions during a time when the system is in use!
-16 1 * * * __KOHA_USER__ $KOHA_CRON_PATH/cleanup_database.pl --confirm --sessions --zebraqueue 10 --list-invites --temp-uploads
+16 1 * * * __KOHA_USER__ $KOHA_CRON_PATH/cleanup_database.pl --confirm --sessions --zebraqueue 10 --list-invites --temp-uploads --del-unv-selfreg 14
# delete old purchase suggestions weekly. Replace XX with a number to define the age of suggestions to delete.
@weekly __KOHA_USER__ $KOHA_CRON_PATH/purge_suggestions.pl --confirm --days XX > /dev/null 2>&1
diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t
index b2c39378a08..4854491198f 100755
--- a/t/db_dependent/Members.t
+++ b/t/db_dependent/Members.t
@@ -411,6 +411,9 @@ subtest 'purgeSelfRegistration' => sub {
foreach(1..3) {
$dbh->do("INSERT INTO borrower_modifications (timestamp, borrowernumber, verification_token, changed_fields) VALUES ('2014-01-01 01:02:03',0,?,'firstname,surname')", undef, (scalar localtime)."_$_");
}
+ # Add a record with a borrowernumber which should not be deleted by DeleteUnverifiedOpacRegistrations
+ # NOTE: We are using the borrowernumber from the last test outside this subtest
+ $dbh->do( "INSERT INTO borrower_modifications (timestamp, borrowernumber, verification_token, changed_fields) VALUES ('2014-01-01 01:02:03', ?, '', 'firstname,surname' )", undef, $borrowernumber );
is( C4::Members::DeleteUnverifiedOpacRegistrations($d), 3, 'Test for DeleteUnverifiedOpacRegistrations' );
#purge members in temporary category
--
2.25.1