Bugzilla – Attachment 119593 Details for
Bug 25183
cleanup-database.pl --del-exp-selfreg fully deletes borrowers - should go into deleted-borrowers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25183: Add option to cleanup-database.pl to move expired self registrations to deleted borrowers table
Bug-25183-Add-option-to-cleanup-databasepl-to-move.patch (text/plain), 5.23 KB, created by
Kyle M Hall (khall)
on 2021-04-14 16:05:09 UTC
(
hide
)
Description:
Bug 25183: Add option to cleanup-database.pl to move expired self registrations to deleted borrowers table
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-04-14 16:05:09 UTC
Size:
5.23 KB
patch
obsolete
>From 36635102d721bf163426aeeed4a390f0180a02ea Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 23 Apr 2020 15:16:17 -0400 >Subject: [PATCH] Bug 25183: Add option to cleanup-database.pl to move expired > self registrations to deleted borrowers table > >The cleanup database job for deleting expired self registrations fully >deletes borrowers instead of transferring them to deleted borrowers. > >This is a problem when libraries think they are deleting email >unverified patrons instead of ones that haven't moved out of the >category, an easy thing to be confused about. > >Test Plan: >1) Apply this patch >2) Try running cleanup_database.pl with the new -del-exp-selfreg-type > parameters 'soft' and 'hard' >3) Param value 'soft' should move patrons to deletedborrowers >4) Param value 'hard' should follow existing behavior >5) Leave our -del-exp-selfreg-type, you should get the existing behavior > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Members.pm | 4 ++++ > misc/cronjobs/cleanup_database.pl | 17 ++++++++++++----- > 2 files changed, 16 insertions(+), 5 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index f98ddecd43..c079f312e7 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -623,12 +623,15 @@ sub IssueSlip { > > =head2 DeleteExpiredOpacRegistrations > >+ $deleted_count = DeleteExpiredOpacRegistrations([$type == "hard|soft"]) >+ > Delete accounts that haven't been upgraded from the 'temporary' category > Returns the number of removed patrons > > =cut > > sub DeleteExpiredOpacRegistrations { >+ my ( $type ) = @_; > > my $delay = C4::Context->preference('PatronSelfRegistrationExpireTemporaryAccountsDelay'); > my $category_code = C4::Context->preference('PatronSelfRegistrationDefaultCategory'); >@@ -645,6 +648,7 @@ sub DeleteExpiredOpacRegistrations { > my $cnt=0; > while ( my $registration = $registrations_to_del->next() ) { > next if $registration->checkouts->count || $registration->account->balance; >+ $registration->move_to_deleted if $type && $type eq 'soft'; > $registration->delete; > $cnt++; > } >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index 4f56e9b4d3..efe56ea6a5 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -27,6 +27,7 @@ use constant DEFAULT_MESSAGES_PURGEDAYS => 365; > use constant DEFAULT_SEARCHHISTORY_PURGEDAYS => 30; > use constant DEFAULT_SHARE_INVITATION_EXPIRY_DAYS => 14; > use constant DEFAULT_DEBARMENTS_PURGEDAYS => 30; >+use constant DEFAULT_EXP_SELFREG_TYPE => 'hard'; > > BEGIN { > # find Koha's Perl modules >@@ -89,9 +90,11 @@ Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] > --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. >- --del-exp-selfreg Delete expired self registration accounts >- --del-unv-selfreg DAYS Delete unverified self registrations older than DAYS >- --unique-holidays DAYS Delete all unique holidays older than DAYS >+ --del-exp-selfreg Delete expired self registration accounts >+ --del-exp-selfreg-type TYPE Option 'hard' completely removes patrons from the database, >+ Option 'soft' moves patron to deleted patrons table. >+ --del-unv-selfreg DAYS Delete unverified self registrations older than DAYS >+ --unique-holidays DAYS Delete all unique holidays older than DAYS > --temp-uploads Delete temporary uploads. > --temp-uploads-days DAYS Override the corresponding preference value. > --uploads-missing FLAG Delete upload records for missing files when FLAG is true, count them otherwise >@@ -127,6 +130,7 @@ my $pListShareInvites; > my $pDebarments; > my $allDebarments; > my $pExpSelfReg; >+my $pExpSelfRegType = 'hard'; > my $pUnvSelfReg; > my $fees_days; > my $special_holidays_days; >@@ -163,6 +167,7 @@ GetOptions( > 'restrictions:i' => \$pDebarments, > 'all-restrictions' => \$allDebarments, > 'del-exp-selfreg' => \$pExpSelfReg, >+ 'del-exp-selfreg-type:s' => \$pExpSelfRegType, > 'del-unv-selfreg' => \$pUnvSelfReg, > 'unique-holidays:i' => \$special_holidays_days, > 'temp-uploads' => \$temp_uploads, >@@ -224,6 +229,7 @@ unless ( $sessions > || $pPseudoTransactionsTo > || $pMessages > || defined $lock_days && $lock_days ne q{} >+ || $pExpSelfRegType !~ m/^hard|soft$/ > ) { > print "You did not specify any cleanup work for the script to do.\n\n"; > usage(1); >@@ -443,7 +449,7 @@ if ($verbose) { > # But non trivial changes to C4::Members need to be done before. > if( $pExpSelfReg ) { > if ( $confirm ) { >- DeleteExpiredSelfRegs(); >+ DeleteExpiredSelfRegs( $pExpSelfRegType ); > } elsif ( $verbose ) { > say "self-registered borrowers may be deleted"; > } >@@ -703,7 +709,8 @@ sub PurgeDebarments { > } > > sub DeleteExpiredSelfRegs { >- my $cnt= C4::Members::DeleteExpiredOpacRegistrations(); >+ my ( $type ) = @_; >+ my $cnt = C4::Members::DeleteExpiredOpacRegistrations( $type ); > print "Removed $cnt expired self-registered borrowers\n" if $verbose; > } > >-- >2.24.3 (Apple Git-128)
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 25183
:
103603
|
103784
|
119019
| 119593 |
119594