From efeb650d7f23a064052f8f2c6fc7ca314ec84897 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 Signed-off-by: David Nind Signed-off-by: Kyle M Hall Signed-off-by: Katrin Fischer (cherry picked from commit 428f6d5b17007da312250a5502c748c1f237fb2d) Signed-off-by: Fridolin Somers --- 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 97097ad3a8..c3e71780cf 100755 --- a/misc/cronjobs/cleanup_database.pl +++ b/misc/cronjobs/cleanup_database.pl @@ -89,8 +89,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. @@ -224,13 +227,24 @@ $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; $jobs_days = DEFAULT_JOBS_PURGEDAYS if defined($jobs_days) && $jobs_days == 0; @jobs_types = (DEFAULT_JOBS_PURGETYPES) if $jobs_days && @jobs_types == 0; $edifact_msg_days = DEFAULT_EDIFACT_MSG_PURGEDAYS if defined($edifact_msg_days) && $edifact_msg_days == 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.39.5