Bugzilla – Attachment 159294 Details for
Bug 23260
Anonymize (remove) patron data from items_last_borrower
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23260: Add cronjob anonymize_last_borrowers.pl
Bug-23260-Add-cronjob-anonymizelastborrowerspl.patch (text/plain), 4.47 KB, created by
Nick Clemens (kidclamp)
on 2023-11-28 13:46:32 UTC
(
hide
)
Description:
Bug 23260: Add cronjob anonymize_last_borrowers.pl
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-11-28 13:46:32 UTC
Size:
4.47 KB
patch
obsolete
>From 531f3d625997acb9787ad6b9cd04648796a6bacb Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 28 Nov 2023 13:31:13 +0000 >Subject: [PATCH] Bug 23260: Add cronjob anonymize_last_borrowers.pl > >This patch adds the feature to anonymize patrons from items_last_borrower table. This code is run from batch_anonymize script, which is triggered from a new cron job anonymize_last_borrowers.pl > >To test: > 1) apply this patch and the previous ones > 2) perl installer/data/mysql/updatedatabase.pl > 3) set StoreLastBorrower preference to Allow. > 4) set AnonymousPatron preference to a valid patron id > 5) Create a Check out followed by a Check in. > CHECK => a row should appear in items_last_borrower table with the borrower and the item number. > 6) In mysql, update created_on of items_last_borrower and returndate of old_issues to two days earlier. > 7) perl misc/cronjobs/anonymize_last_borrowers.pl > CHECK => borrower number in items_last_borrower is not anonymized yet. > 8) Repeat step 5 and 6 but instead of two days earlier, set the new entry in items_last_borrower to three days earlier. > 9) set AnonymizeLastBorrower to 'Anonymize' and AnonymizeLastBorrowerDays to 2 days. >10) perl misc/cronjobs/anonymize_last_borrowers.pl > SUCCESS => borrower number in items_last_borrower changed to AnonymousPatron id >11) repeat step 8 >12) set AnonymousPatron preference to 0 >13) perl misc/cronjobs/anonymize_last_borrowers.pl >SUCCESS => borrower number in items_last_borrower changed to null >14) prove t/db_dependent/Koha/Patrons.t >--- > debian/koha-common.cron.daily | 1 + > misc/cronjobs/anonymize_last_borrowers.pl | 70 +++++++++++++++++++++++ > 2 files changed, 71 insertions(+) > create mode 100755 misc/cronjobs/anonymize_last_borrowers.pl > >diff --git a/debian/koha-common.cron.daily b/debian/koha-common.cron.daily >index 0d960ef0c5d..b6e16d084f1 100644 >--- a/debian/koha-common.cron.daily >+++ b/debian/koha-common.cron.daily >@@ -30,4 +30,5 @@ koha-foreach --chdir --enabled --noemail /usr/share/koha/bin/cronjobs/cleanup_da > koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/auto_unsuspend_holds.pl > /dev/null 2>&1 > koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/merge_authorities.pl -b > koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/plugins_nightly.pl >+koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/anonymize_last_borrowers.pl > koha-run-backups --days 2 --output /var/spool/koha >diff --git a/misc/cronjobs/anonymize_last_borrowers.pl b/misc/cronjobs/anonymize_last_borrowers.pl >new file mode 100755 >index 00000000000..06eef8601df >--- /dev/null >+++ b/misc/cronjobs/anonymize_last_borrowers.pl >@@ -0,0 +1,70 @@ >+#!/usr/bin/perl >+ >+# Copyright 2011, ByWater Solutions. >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+BEGIN { >+ >+ # find Koha's Perl modules >+ # test carefully before changing this >+ use FindBin; >+ eval { require "$FindBin::Bin/../kohalib.pl" }; >+} >+ >+use Koha::Script -cron; >+use C4::Context; >+use Koha::Patrons; >+use Getopt::Long; >+use C4::Log; >+ >+sub usage { >+ print STDERR <<USAGE; >+Usage: $0 [-h|--help] >+ -v --verbose gives a little more information >+ -h --help prints this help message, and exits, ignoring all >+ other options >+Note: If the system preference 'AnonymousPatron' is not defined, NULL will be used. >+USAGE >+ exit $_[0]; >+} >+ >+my ( $help, $verbose ); >+ >+GetOptions( >+ 'h|help' => \$help, >+ 'v|verbose' => \$verbose, >+) || usage(1); >+ >+if ($help) { >+ usage(0); >+} >+ >+my $pref = C4::Context->preference("AnonymizeLastBorrower"); >+ >+if ( !$pref ) { >+ print "Preference 'AnonymizeLastBorrower' must be enabled to anonymize item's last borrower\n\n"; >+ usage(1); >+} >+ >+cronlogaction(); >+ >+my $rows = Koha::Patrons->anonymize_last_borrowers(); >+$verbose and print int($rows) . " item's last borrowers anonymized.\n"; >+ >+exit(0); >-- >2.30.2
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 23260
:
92863
|
92864
|
93052
|
94858
|
94859
|
95033
|
95457
|
95458
|
95459
|
95460
|
95651
|
95698
|
95699
|
95700
|
95701
|
95769
|
95770
|
95771
|
95772
|
96791
|
97841
|
97842
|
98044
|
98053
|
98054
|
98064
|
98282
|
98349
|
98352
|
112734
|
112735
|
112736
|
112737
|
112738
|
112739
|
112740
|
112741
|
112742
|
112743
|
117974
|
117975
|
117976
|
117977
|
117978
|
117979
|
117980
|
117981
|
117982
|
117983
|
120522
|
120523
|
120524
|
120525
|
120526
|
120527
|
120528
|
120529
|
120530
|
120531
|
122963
|
122964
|
122965
|
122966
|
122967
|
122968
|
122969
|
122970
|
122971
|
122972
|
145175
|
145176
|
145177
|
145178
|
145179
|
145180
|
145181
|
145182
|
145183
|
145184
|
157106
|
157107
|
157108
|
157109
|
157110
|
157111
|
157112
|
157113
|
157114
|
157115
|
157116
|
159291
|
159292
|
159293
|
159294
|
159298
|
159299
|
159300
|
159301
|
164129
|
164130
|
164131
|
164132
|
164133