Bugzilla – Attachment 155964 Details for
Bug 31143
We should attempt to fix/identify all cases where '0000-00-00' may still remain in the database
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31143: Update patrons with dates of 0000-00-00 to NULL
Bug-31143-Update-patrons-with-dates-of-0000-00-00-.patch (text/plain), 2.47 KB, created by
David Nind
on 2023-09-20 23:49:00 UTC
(
hide
)
Description:
Bug 31143: Update patrons with dates of 0000-00-00 to NULL
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-09-20 23:49:00 UTC
Size:
2.47 KB
patch
obsolete
>From ca70f5093b6993f1c0ba697ef2e32eb5b58ef44a Mon Sep 17 00:00:00 2001 >From: Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz> >Date: Mon, 7 Aug 2023 15:46:45 +1200 >Subject: [PATCH] Bug 31143: Update patrons with dates of 0000-00-00 to NULL > >To test: >1) Change a patron's value of one or more of the following to >0000-00-00: dateofbirth dateenrolled dateexpiry date_renewed >2) Run the fix_patron_dates.pl (-c -v) >3) Notice the value has changed from 0000-00-00 to NULL > >Sponsored by: Toi Ohomai Institute of Technology, New Zealand > >Signed-off-by: David Nind <david@davidnind.com> >--- > misc/cronjobs/fix_patron_dates.pl | 54 +++++++++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > create mode 100755 misc/cronjobs/fix_patron_dates.pl > >diff --git a/misc/cronjobs/fix_patron_dates.pl b/misc/cronjobs/fix_patron_dates.pl >new file mode 100755 >index 0000000000..af97d2a177 >--- /dev/null >+++ b/misc/cronjobs/fix_patron_dates.pl >@@ -0,0 +1,54 @@ >+#!/usr/bin/perl >+ >+# 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; >+ >+use C4::Context; >+use C4::Log qw(cronlogaction); >+use Getopt::Long qw( GetOptions ); >+use Pod::Usage qw( pod2usage ); >+use Koha::Logger; >+use Koha::Patrons; >+use Koha::DateUtils qw( dt_from_string ); >+use Koha::Script -cron; >+use Data::Dumper; >+ >+my $verbose = 0; >+my $doit = 0; >+ >+GetOptions( >+ 'v|verbose' => \$verbose, >+ 'c|confirm' => \$doit, >+); >+ >+my $count; >+ >+# search patrons that have date fields that are 0000-00-00 >+foreach my $date_type (qw(dateofbirth dateenrolled dateexpiry date_renewed)) { >+ my $borrowers = Koha::Patrons->search( { $date_type=>'0000-00-00' } ); >+ >+ if ($doit) { # if confirm flag was run with cronjob >+ while (my $borrower = $borrowers->next()) { >+ $count++; >+ $borrower->$date_type(undef)->store(); >+ } >+ } >+} >+ >+if ($verbose) { >+ print "$count wrong dates found"; >+} >-- >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 31143
:
154299
|
154399
|
155964
|
168636
|
168770
|
168775
|
168776
|
170086
|
170697
|
170698
|
171812
|
171813
|
171814
|
171815
|
171816
|
171817
|
171918
|
171976
|
171977
|
172138
|
172139
|
172140
|
172141
|
172143
|
172144
|
172145
|
172146
|
173900