Bugzilla – Attachment 80403 Details for
Bug 21336
GDPR: Handle unsubscribe requests automatically by optional (administrative) lock, anonymize and remove
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21336: Adjust cleanup_database.pl
Bug-21336-Adjust-cleanupdatabasepl.patch (text/plain), 4.34 KB, created by
Marcel de Rooy
on 2018-10-11 12:13:00 UTC
(
hide
)
Description:
Bug 21336: Adjust cleanup_database.pl
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-10-11 12:13:00 UTC
Size:
4.34 KB
patch
obsolete
>From 792b6f5af17b48f641fee28f381402dc2d35a28f Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 12 Sep 2018 14:25:26 +0200 >Subject: [PATCH] Bug 21336: Adjust cleanup_database.pl >Content-Type: text/plain; charset=utf-8 > >Add the new Patron routines to this cron job. Actions are performed only if >preferences are set. > >Note: No specific command line flags for these actions are added here >(and probably not needed too). So no crontab changes too. > >Test plan: >Add a new patron. >Enable GDPR_Policy and refuse consent on OPAC for this patron. >Set only the first delay to zero (0) for immediate action. >Run cleanup_database.pl --logs (or any other flag) for the first time. >Check lock and expiration. >Set the second delay to zero (0) for immediate action. >Run cleanup_database.pl --logs for the second time. Check anonymization. >Set the third delay to zero (0) for immediate action. >Run cleanup_database.pl --logs for the third time. Check removal. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Amended: Added the warn $@ line in cleanup_database.pl >--- > Koha/Patrons.pm | 20 ++++++++++++++++---- > misc/cronjobs/cleanup_database.pl | 8 ++++++++ > 2 files changed, 24 insertions(+), 4 deletions(-) > >diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm >index 6ab55f9..e6bb76d 100644 >--- a/Koha/Patrons.pm >+++ b/Koha/Patrons.pm >@@ -210,7 +210,7 @@ sub anonymise_issue_history { > > =head3 delete > >- Koha::Patrons->search({ some filters here })->delete({ move => 1 }); >+ Koha::Patrons->search({ some filters here })->delete({ move => 1, verbose => 1 }); > > Delete passed set of patron objects. > Wrapper for Koha::Patron->delete. (We do not want to bypass Koha::Patron >@@ -226,10 +226,12 @@ sub delete { > my ( $self, $params ) = @_; > $self->_resultset->result_source->schema->txn_do( sub { > my ( $set, $params ) = @_; >+ my $count = $set->count; > while( my $patron = $set->next ) { > $patron->move_to_deleted if $params->{move}; > $patron->delete == 1 || Koha::Exceptions::Patron::Delete->throw; > } >+ warn "Deleted $count patrons\n" if $params->{verbose}; > }, $self, $params ); > return 1; > } >@@ -326,34 +328,44 @@ sub search_anonymized { > > =head3 lock > >- Koha::Patrons->search({ some filters })->lock({ expire => 1, remove => 1 }) >+ Koha::Patrons->search({ some filters })->lock({ expire => 1, remove => 1, verbose => 1 }) > > Lock the passed set of patron objects. Optionally expire and remove holds. >+ Optional verbose flag is used in cron job. > Wrapper around Koha::Patron->lock. > > =cut > > sub lock { > my ( $self, $params ) = @_; >+ my $count = $self->count; > while( my $patron = $self->next ) { > $patron->lock($params); > } >+ if( $params->{verbose} ) { >+ warn "Locked $count patrons\n"; >+ } > } > > =head3 anonymize > >- Koha::Patrons->search({ some filters })->anonymize; >+ Koha::Patrons->search({ some filters })->anonymize({ verbose => 1 }); > > Anonymize passed set of patron objects. >+ Optional verbose flag is used in cron job. > Wrapper around Koha::Patron->anonymize. > > =cut > > sub anonymize { >- my ( $self ) = @_; >+ my ( $self, $params ) = @_; >+ my $count = $self->count; > while( my $patron = $self->next ) { > $patron->anonymize; > } >+ if( $params->{verbose} ) { >+ warn "Anonymized $count patrons\n"; >+ } > } > > =head3 _type >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index 3e6c504..50fe525 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -304,6 +304,14 @@ if($allDebarments) { > print "$count restrictions were deleted.\nDone with all restrictions purge.\n" if $verbose; > } > >+# Handle unsubscribe requests from GDPR consent form, depends on UnsubscribeReflectionDelay preference >+Koha::Patrons->search_unsubscribed->lock({ expire => 1, remove => 1, verbose => $verbose }); >+# Anonymize patron data, depending on PatronAnonymizeDelay >+Koha::Patrons->search_anonymize_candidates({ locked => 1 })->anonymize({ verbose => $verbose }); >+# Remove patron data, depending on PatronRemovalDelay (will raise an exception if problem encountered >+eval { Koha::Patrons->search_anonymized->delete({ move => 1, verbose => $verbose }) }; >+warn $@ if $@; >+ > if( $pExpSelfReg ) { > DeleteExpiredSelfRegs(); > } >-- >2.1.4
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 21336
:
79165
|
79166
|
79167
|
79168
|
79169
|
79170
|
80201
|
80202
|
80203
|
80204
|
80205
|
80206
|
80207
|
80208
|
80213
|
80214
|
80386
|
80387
|
80403
|
81112
|
81113
|
81114
|
81115
|
81116
|
81117
|
81118
|
81119
|
81270
|
81474
|
81475
|
81476
|
81477
|
81478
|
81479
|
81480
|
81481
|
81482
|
81483
|
82051
|
82052
|
82053
|
82054
|
82055
|
82056
|
82057
|
82058
|
82059
|
83202
|
83203
|
83204
|
83205
|
83206
|
83207
|
83208
|
83209
|
83256
|
87158
|
87159
|
87160
|
87161
|
87162
|
87163
|
87164
|
87165
|
87166
|
87167
|
87168
|
87176
|
87177
|
87178
|
87179
|
87180
|
87181
|
87182
|
87183
|
87184
|
87185
|
87387
|
87388
|
87389
|
87390
|
87391
|
87392
|
87393
|
87394
|
87395
|
87396
|
87397
|
87400
|
87401
|
88198
|
88199
|
88217
|
88218