From 51b75e633410ce95d14c591be0f7c817bb5dedc2 Mon Sep 17 00:00:00 2001 From: Wainui Witika-Park Date: Tue, 9 Jul 2024 18:16:31 +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 lastseen updated_on debarred 2) Run the misc/maintenance/search_for_data_inconsistencies.pl script 3) Notice the value has changed from 0000-00-00 to NULL Sponsored by: Toi Ohomai Institute of Technology, New Zealand --- misc/maintenance/search_for_data_inconsistencies.pl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/misc/maintenance/search_for_data_inconsistencies.pl b/misc/maintenance/search_for_data_inconsistencies.pl index 6719cecedc9..3c6012a07cd 100755 --- a/misc/maintenance/search_for_data_inconsistencies.pl +++ b/misc/maintenance/search_for_data_inconsistencies.pl @@ -326,6 +326,16 @@ use C4::Biblio qw( GetMarcFromKohaField ); } } +{ + # search patrons that have date fields that are 0000-00-00 + foreach my $date_type (qw(dateofbirth dateenrolled dateexpiry date_renewed lastseen updated_on_debarred)) { + my $borrowers = Koha::Patrons->search( { $date_type=>'0000-00-00' } ); + while (my $borrower = $borrowers->next()) { + $borrower->$date_type(undef)->store(); + } + } +} + { my @loop_borrowers_relationships; my @guarantor_ids = Koha::Patron::Relationships->_resultset->get_column('guarantor_id')->all(); -- 2.39.2