Bugzilla – Attachment 172141 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: (QA follow-up) Tidy
Bug-31143-QA-follow-up-Tidy.patch (text/plain), 4.53 KB, created by
Nick Clemens (kidclamp)
on 2024-09-27 17:46:08 UTC
(
hide
)
Description:
Bug 31143: (QA follow-up) Tidy
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-09-27 17:46:08 UTC
Size:
4.53 KB
patch
obsolete
>From 3a09e64423be98f9a7e0de0fd728706f15e468d9 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 27 Sep 2024 17:45:01 +0000 >Subject: [PATCH] Bug 31143: (QA follow-up) Tidy > >--- > misc/maintenance/fix_invalid_dates.pl | 26 +++++++++++-------- > .../search_for_data_inconsistencies.pl | 13 ++++++---- > 2 files changed, 23 insertions(+), 16 deletions(-) > >diff --git a/misc/maintenance/fix_invalid_dates.pl b/misc/maintenance/fix_invalid_dates.pl >index a7f43b671d5..2da8b1c457e 100755 >--- a/misc/maintenance/fix_invalid_dates.pl >+++ b/misc/maintenance/fix_invalid_dates.pl >@@ -18,9 +18,9 @@ > use Modern::Perl; > > use C4::Context; >-use C4::Log qw(cronlogaction); >+use C4::Log qw(cronlogaction); > use Getopt::Long qw( GetOptions ); >-use Pod::Usage qw( pod2usage ); >+use Pod::Usage qw( pod2usage ); > use Koha::Logger; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Script -cron; >@@ -28,38 +28,42 @@ use Data::Dumper; > use Koha::Database; > > my $verbose = 0; >-my $doit = 0; >+my $doit = 0; > > GetOptions( >- 'v|verbose' => \$verbose, >- 'c|confirm' => \$doit, >+ 'v|verbose' => \$verbose, >+ 'c|confirm' => \$doit, > ); > > my $schema = Koha::Database->new->schema; >+ > # Loop over all the DBIx::Class classes >-for my $class ( sort values %{$schema->{class_mappings}} ) { >+for my $class ( sort values %{ $schema->{class_mappings} } ) { >+ > # Retrieve the resultset so we can access the columns info >- my $rs = $schema->resultset($class); >+ my $rs = $schema->resultset($class); > my $columns = $rs->result_source->columns_info; > > # Loop over the columns > while ( my ( $column, $info ) = each %$columns ) { >+ > # Next if data type is not date/datetime/timestamp > my $data_type = $info->{data_type}; > next unless grep { $data_type =~ m{^$_$} } qw( timestamp datetime date ); > > # Count the invalid dates >- my $invalid_dates = $rs->search({ $column => '0000-00-00' })->count; >+ my $invalid_dates = $rs->search( { $column => '0000-00-00' } )->count; > > next unless $invalid_dates; > >- if ($verbose) { >+ if ($verbose) { > say sprintf "Column %s.%s contains %s invalid dates", $rs->result_source->name, $column, $invalid_dates; > } > > if ($doit) { >- $rs->search({ $column => '0000-00-00' })->update({ $column => undef }); >- say sprintf "Column %s.%s contains %s invalid dates that have been fixed", $rs->result_source->name, $column, $invalid_dates; >+ $rs->search( { $column => '0000-00-00' } )->update( { $column => undef } ); >+ say sprintf "Column %s.%s contains %s invalid dates that have been fixed", $rs->result_source->name, >+ $column, $invalid_dates; > } > > } >diff --git a/misc/maintenance/search_for_data_inconsistencies.pl b/misc/maintenance/search_for_data_inconsistencies.pl >index ed29e4134ff..4c0eddf792f 100755 >--- a/misc/maintenance/search_for_data_inconsistencies.pl >+++ b/misc/maintenance/search_for_data_inconsistencies.pl >@@ -331,25 +331,28 @@ use C4::Biblio qw( GetMarcFromKohaField ); > my $schema = Koha::Database->new->schema; > > # Loop over all the DBIx::Class classes >- for my $class ( sort values %{$schema->{class_mappings}} ) { >+ for my $class ( sort values %{ $schema->{class_mappings} } ) { >+ > # Retrieve the resultset so we can access the columns info >- my $rs = $schema->resultset($class); >+ my $rs = $schema->resultset($class); > my $columns = $rs->result_source->columns_info; > > # Loop over the columns > while ( my ( $column, $info ) = each %$columns ) { >+ > # Next if data type is not date/datetime/timestamp > my $data_type = $info->{data_type}; > next unless grep { $data_type =~ m{^$_$} } qw( timestamp datetime date ); > > # Count the invalid dates >- my $invalid_dates = $rs->search({ $column => '0000-00-00' })->count; >+ my $invalid_dates = $rs->search( { $column => '0000-00-00' } )->count; > > next unless $invalid_dates; > >- new_section("Column " . $rs->result_source->name . "." . $column . " contains $invalid_dates invalid dates"); >+ new_section( >+ "Column " . $rs->result_source->name . "." . $column . " contains $invalid_dates invalid dates" ); > >- if ($invalid_dates > 0) { >+ if ( $invalid_dates > 0 ) { > new_hint("You may change the dates with script: misc/cronjobs/fix_invalid_dates.pl (-c -v)"); > } > >-- >2.39.5
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