Bugzilla – Attachment 112634 Details for
Bug 26831
Enable librarians to control when unaccepted private list share invites are removed by the cleanup_database.pl cronjob
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26831: Add a system preference to define the number of days used for purging unaccepted list share invites in cleanup_database.pl
Bug-26831-Add-a-system-preference-to-define-the-nu.patch (text/plain), 8.83 KB, created by
Alex Buckley
on 2020-10-28 10:35:22 UTC
(
hide
)
Description:
Bug 26831: Add a system preference to define the number of days used for purging unaccepted list share invites in cleanup_database.pl
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2020-10-28 10:35:22 UTC
Size:
8.83 KB
patch
obsolete
>From ac587457691d53f3685181fc5e4fe15993574414 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Wed, 28 Oct 2020 09:46:50 +0000 >Subject: [PATCH] Bug 26831: Add a system preference to define the number of > days used for purging unaccepted list share invites in cleanup_database.pl > >The PurgeUnacceptedListShareInvitesOlderThan system preference value >is used whenever the cleanup_database.pl cron job is called without the >--list-invites parameter. > >If neither the system preference or the --list-invites parameter has a >value then the cronjob errors out. > >Test plan: >1. Apply patch >2. Update database: >sudo koha-shell <instancename> >cd installer/data/mysql >./updatedatabase.pl > >3. Confirm the default value of the >PurgeUnacceptedListShareInvitesOlderThan system preference is 14 > >4. Run the cleanup_database.pl script without the --list-invites parameter: >sudo koha-shell <instancename> >cd misc/cronjobs >./cleanup_database.pl -v > >5. Confirm the following text is included in the output: >"Purging unaccepted list share invites older than 14 days." > >6. Clear the aforementioned system preference. Run the cleanup_database.pl cron job with >the --list-invites parameter defined: >./cleanup_database.pl --list-invites 10 -v > >7. Confirm the following text is included in the output: >"Purging unaccepted list share invites older than 10 days." > >8. Input a value of 20 into the aforementioned system preference. Run the cron job with --list-invites defined: >./cleanup_database.pl --list-invites 10 -v > >9. Confirm the following text is included in the output: >"Purging unaccepted list share invites older than 10 days." > >10. Clear the aforementioned system preference value and run the cron job without the >--list-invites parameter: >./cleanup_database.pl -v > >11. Confirm the following text is included in the output: >"You did not specify any cleanup work for the script to do" > >Sponsored-by: Catalyst IT >--- > ...dd_PurgeUnacceptedListShareInvitesOlderThan-syspref.perl | 6 ++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../prog/en/modules/admin/preferences/opac.pref | 6 ++++++ > misc/cronjobs/cleanup_database.pl | 13 +++++++++---- > 4 files changed, 22 insertions(+), 4 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_26831-add_PurgeUnacceptedListShareInvitesOlderThan-syspref.perl > >diff --git a/installer/data/mysql/atomicupdate/bug_26831-add_PurgeUnacceptedListShareInvitesOlderThan-syspref.perl b/installer/data/mysql/atomicupdate/bug_26831-add_PurgeUnacceptedListShareInvitesOlderThan-syspref.perl >new file mode 100644 >index 00000000000..262ab530562 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_26831-add_PurgeUnacceptedListShareInvitesOlderThan-syspref.perl >@@ -0,0 +1,6 @@ >+$DBversion = 'XXX'; >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('PurgeUnacceptedListShareInvitesOlderThan', '14', NULL, 'If not empty, number of days used when deleting unaccepted list share invites', 'Integer') }); >+ >+ NewVersion( $DBversion, 26831, "Replace 'list-invites' parameter with system preference in cleanup_database.pl cronjob"); >+} >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 0e9f4880559..c02f6e0755f 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -528,6 +528,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('PseudonymizationPatronFields','','title,city,state,zipcode,country,branchcode,categorycode,dateenrolled,sex,sort1,sort2','Patron fields to copy to the pseudonymized_transactions table','multiple'), > ('PseudonymizationTransactionFields','','datetime,branchcode,transaction_type,itemnumber,itemtype,holdingbranch,location,itemcallnumber,ccode','Transaction fields to copy to the pseudonymized_transactions table','multiple'), > ('PurgeSuggestionsOlderThan', '', NULL, 'If this script is called without the days parameter', 'Integer'), >+('PurgeUnacceptedListShareInvitesOlderThan', '14', NULL, 'If not empty, number of days used when deleting unaccepted list share invites', 'Integer'), > ('QueryAutoTruncate','1',NULL,'If ON, query truncation is enabled by default','YesNo'), > ('QueryFuzzy','1',NULL,'If ON, enables fuzzy option for searches','YesNo'), > ('QueryRegexEscapeOptions', 'escape', 'dont_escape|escape|unescape_escaped', 'Escape option for regexps delimiters in Elasicsearch queries.', 'Choice'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 3d8cd4fab9a..79a8c5de6cf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -672,6 +672,12 @@ OPAC: > no: "Don't block" > - expired patrons from OPAC actions such as placing a hold or renewing. Note that the setting for a patron category takes priority over this system preference. > - >+ - The cleanup_database.pl cronjob will automatically delete unaccepted private list share invites after a period of >+ - pref: PurgeUnacceptedListShareInvitesOlderThan >+ class: integer >+ - "days. Example: [14] Sets purgation of unaccepted private list share invites for those older than 14 days." >+ - "<br><strong>Note:</strong> If you leave this field empty then, the cronjob will not delete any unaccepted private list share invites." >+ - > - Limit patrons to > - pref: MaxOpenSuggestions > class: integer >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index c2d8e9832c2..572a4e95395 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -24,7 +24,6 @@ use constant DEFAULT_MAIL_PURGEDAYS => 30; > use constant DEFAULT_IMPORT_PURGEDAYS => 60; > use constant DEFAULT_LOGS_PURGEDAYS => 180; > use constant DEFAULT_SEARCHHISTORY_PURGEDAYS => 30; >-use constant DEFAULT_SHARE_INVITATION_EXPIRY_DAYS => 14; > use constant DEFAULT_DEBARMENTS_PURGEDAYS => 30; > > BEGIN { >@@ -81,7 +80,11 @@ Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] > --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. >+ days. >+ If this parameter is not defined, then the cron job falls back to the >+ value of system preference PurgeUnacceptedListShareInvitesOlderThan. >+ If neither the parameter, nor the system preference are defined then no >+ unaccepted list share invite will be purged. > --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. >@@ -180,7 +183,7 @@ $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; >+$pListShareInvites = C4::Context->preference('PurgeUnacceptedListShareInvitesOlderThan') if !defined($pListShareInvites); #If no --list-invites parameter has been used when calling this script fall back to using the PurgeUnacceptedListShareInvitesOlderThan system preference value. > $pDebarments = DEFAULT_DEBARMENTS_PURGEDAYS if defined($pDebarments) && $pDebarments == 0; > > if ($help) { >@@ -346,7 +349,7 @@ if ($pSearchhistory) { > print "Done with purging search_history.\n" if $verbose; > } > >-if ($pListShareInvites) { >+if ($pListShareInvites && $pListShareInvites > 0) { > print "Purging unaccepted list share invites older than $pListShareInvites days.\n" if $verbose; > $sth = $dbh->prepare( > q{ >@@ -359,6 +362,8 @@ if ($pListShareInvites) { > $sth->execute($pListShareInvites); > } > print "Done with purging unaccepted list share invites.\n" if $verbose; >+} elsif ($pListShareInvites <= 0) { >+ print "This script requires a positive number of days at which to purge unaccepted list share invites. Aborted.\n"; > } > > if ($pDebarments) { >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26831
:
112634
|
140747
|
140748
|
140749
|
140750
|
140751
|
140752
|
157684
|
157685
|
157686
|
157711
|
157712
|
157713
|
157714
|
159097
|
159098
|
159099
|
159100
|
159101
|
159102