From cc1695ba96b79d85fe778af1c60b092b149dd449 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Mon, 24 Apr 2023 20:05:50 -1000 Subject: [PATCH] Bug 33603: Fix misc/maintenance/search_for_data_inconsistencies.pl when biblio.biblionumber on control field Since bug 29486, misc/maintenance/search_for_data_inconsistencies.pl search for biblio.biblionumber in MARC record with $record->subfield(). This fails when field is a control field (< 10). Idem for biblioitems.biblioitemnumber Test plan : 1.0) On a UNIMARC database (biblio.biblionumber is on 001) 1.1) Run misc/maintenance/search_for_data_inconsistencies.pl => Without patch you get error : Control fields (generally, just tags below 010) do not have subfields, use data() => With patch no error 2.0) On a MARC21 database (biblio.biblionumber is on 999c) 2.1) Run misc/maintenance/search_for_data_inconsistencies.pl => Check you see no error Signed-off-by: David Nind Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- .../search_for_data_inconsistencies.pl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/misc/maintenance/search_for_data_inconsistencies.pl b/misc/maintenance/search_for_data_inconsistencies.pl index 7e1befef92..98f69215cd 100755 --- a/misc/maintenance/search_for_data_inconsistencies.pl +++ b/misc/maintenance/search_for_data_inconsistencies.pl @@ -129,8 +129,19 @@ use C4::Biblio qw( GetMarcFromKohaField ); push @decoding_errors, $@; next; } - my $biblionumber = $record->subfield($biblio_tag, $biblio_subfield); - my $biblioitemnumber = $record->subfield($biblioitem_tag, $biblioitem_subfield); + my ( $biblionumber, $biblioitemnumber ); + if ( $biblio_tag < 10 ) { + my $biblio_control_field = $record->field($biblio_tag); + $biblionumber = $biblio_control_field->data if $biblio_control_field; + } else { + $biblionumber = $record->subfield( $biblio_tag, $biblio_subfield ); + } + if ( $biblioitem_tag < 10 ) { + my $biblioitem_control_field = $record->field($biblioitem_tag); + $biblioitemnumber = $biblioitem_control_field->data if $biblioitem_control_field; + } else { + $biblioitemnumber = $record->subfield( $biblioitem_tag, $biblioitem_subfield ); + } if ( $biblionumber != $biblio->biblionumber ) { push @ids_not_in_marc, { -- 2.39.5