From 01bba470680debe405f43b96d0891c5a93cc88a7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 19 Jan 2022 14:40:14 +0100 Subject: [PATCH] Bug 29486: Add check in search_for_data_inconsistencies.pl If the MARC record does not contain the correct biblionumber of biblioitemnumber, the script will display the following warning: == Bibliographic records have MARCXML without biblionumber or biblioitemnumber == * Biblionumber 4242 has '1' in 999$c * Biblionumber 4242 has biblioitemnumber '4242' but should be '1' in 999$d => The bibliographic records must have the biblionumber and biblioitemnumber in MARCXML Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers Signed-off-by: Tomas Cohen Arazi --- .../search_for_data_inconsistencies.pl | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/misc/maintenance/search_for_data_inconsistencies.pl b/misc/maintenance/search_for_data_inconsistencies.pl index c2c94d490c..8a7309208f 100755 --- a/misc/maintenance/search_for_data_inconsistencies.pl +++ b/misc/maintenance/search_for_data_inconsistencies.pl @@ -118,8 +118,10 @@ use C4::Biblio qw( GetMarcFromKohaField ); } } - my @decoding_errors; + my ( @decoding_errors, @ids_not_in_marc ); my $biblios = Koha::Biblios->search; + my ( $biblio_tag, $biblio_subfield ) = C4::Biblio::GetMarcFromKohaField( "biblio.biblionumber" ); + my ( $biblioitem_tag, $biblioitem_subfield ) = C4::Biblio::GetMarcFromKohaField( "biblioitems.biblioitemnumber" ); while ( my $biblio = $biblios->next ) { my $record = eval{$biblio->metadata->record;}; if ($@) { @@ -160,6 +162,33 @@ use C4::Biblio qw( GetMarcFromKohaField ); new_item($_) for @decoding_errors; new_hint("The bibliographic records must have a valid MARCXML or you will face encoding issues or wrong displays"); } + if (@ids_not_in_marc) { + new_section("Bibliographic records have MARCXML without biblionumber or biblioitemnumber"); + for my $id (@ids_not_in_marc) { + if ( exists $id->{biblioitemnumber} ) { + new_item( + sprintf(q{Biblionumber %s has biblioitemnumber '%s' but should be '%s' in %s$%s}, + $id->{biblionumber}, + $id->{biblioitemnumber}, + $id->{biblioitemnumber_in_marc}, + $biblioitem_tag, + $biblioitem_subfield, + ) + ); + } + else { + new_item( + sprintf(q{Biblionumber %s has '%s' in %s$%s}, + $id->{biblionumber}, + $id->{biblionumber_in_marc}, + $biblio_tag, + $biblio_subfield, + ) + ); + } + } + new_hint("The bibliographic records must have the biblionumber and biblioitemnumber in MARCXML"); + } } { -- 2.39.5