From 670da50b031a6ef1aed436757a7c1e47c4c5c73e Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Tue, 13 Sep 2022 12:09:14 +1200 Subject: [PATCH] Bug 26831: Use new PurgeListShareInvitesOlderThan syspref Enable librarians in the staff client to control when unaccepted list invites will be removed from the database. Test plan: 1. Apply patches 2. Update database sudo koha-shell cd installer/data/mysql ./updatedatabase.pl 3. Confirm the PurgeListShareInvitesOlderThan syspref = 14 4. Run cleanup_database.pl with --list-invites parameter defined: sudo koha-shell cd misc/cronjobs ./cleanup_database.pl --list-invites 10 -v 5. Confirm the output contains: "Purging unaccepted list share invites older than 10 days." 6. Set PurgeListShareInvitesOlderThan syspref = 15 7. Run cleanup_database.pl without the --list-invites parameter: sudo koha-shell cd misc/cronjobs ./cleanup_database.pl -v 8. Confirm the output contains: "Purging unaccepted list share invites older than 15 days." 9. Empty PurgeListShareInvitesOlderThan syspref 10. Run cleanup_database without the --list-invites parameter: sudo koha-shell cd misc/cronjobs ./cleanup_database.pl --list-invites -v 13. Confirm the output contains: "Purging unaccepted list share invites older than 14 days." Sponsored-by: Catalyst IT, New Zealand --- misc/cronjobs/cleanup_database.pl | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl index 74505cf067e..5b04b29542a 100755 --- a/misc/cronjobs/cleanup_database.pl +++ b/misc/cronjobs/cleanup_database.pl @@ -80,8 +80,11 @@ Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] Defaults to 180 days if no days specified. --searchhistory DAYS purge entries from search_history older than DAYS days. Defaults to 30 days if no days specified - --list-invites DAYS purge (unaccepted) list share invites older than DAYS - days. Defaults to 14 days if no days specified. + --list-invites DAYS purge (unaccepted) list share invites older than DAYS days. + This parameter is prioritised over the + PurgeListShareInvitesOlderThan system preference. + Defaults to 14 days if no days specified for this parameter and + the PurgeListShareInvitesOlderThan system preference is empty. --restrictions DAYS purge patrons restrictions expired since more than DAYS days. Defaults to 30 days if no days specified. --all-restrictions purge all expired patrons restrictions. @@ -197,10 +200,21 @@ $pLogs = DEFAULT_LOGS_PURGEDAYS if defined($pLogs) $zebraqueue_days = DEFAULT_ZEBRAQ_PURGEDAYS if defined($zebraqueue_days) && $zebraqueue_days == 0; $mail = DEFAULT_MAIL_PURGEDAYS if defined($mail) && $mail == 0; $pSearchhistory = DEFAULT_SEARCHHISTORY_PURGEDAYS if defined($pSearchhistory) && $pSearchhistory == 0; -$pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0; $pDebarments = DEFAULT_DEBARMENTS_PURGEDAYS if defined($pDebarments) && $pDebarments == 0; $pMessages = DEFAULT_MESSAGES_PURGEDAYS if defined($pMessages) && $pMessages == 0; +# Choose the number of days at which to purge unaccepted list invites: +# - DAYS defined in the list-invites parameter is prioritised first +# - PurgeListShareInvitesOlderThan system preference is prioritised second +# - Default value of 14 days is prioritised last - if the list-invites parameter is passed without a DAYS value and the PurgeListShareInvitesOlderThan syspref is empty. +if ( !defined($pListShareInvites) ) { + if ( C4::Context->preference('PurgeListShareInvitesOlderThan') ) { + $pListShareInvites = C4::Context->preference('PurgeListShareInvitesOlderThan'); + } +} elsif ( defined($pListShareInvites) && $pListShareInvites == 0 ) { + $pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS; +} + if ($help) { usage(0); } -- 2.20.1