From f38b7598fca79e0f7059405b2714d91b0eca96ee Mon Sep 17 00:00:00 2001 From: Paul POULAIN Date: Mon, 19 Nov 2007 18:55:21 +0100 Subject: [PATCH] still handling better dirty MARC records this time it's when a biblio don't have biblionumber, has a 100$a field, and it's invalid. 1 biblio in my 300 000 DB (and it was biblio 294 359, of course !) Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- misc/migration_tools/rebuild_zebra.pl | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl index 3373df39ad..60f26eb91d 100755 --- a/misc/migration_tools/rebuild_zebra.pl +++ b/misc/migration_tools/rebuild_zebra.pl @@ -584,14 +584,17 @@ rank:rank-1 next; } next unless $record; -# warn $record->as_formatted; # die if $record->subfield('090','9') eq 11; # print $record; # check that biblionumber & biblioitemnumber are stored in the MARC record, otherwise, add them & update the biblioitems.marcxml data. my $record_correct=1; # skip uncorrect records : isn't this bogus, as just after we reintroduce biblionumber if it's missing ? # FIXME next unless $record->field($biblionumbertagfield); - # check if biblionumber is present, otherwise, add it on the fly + # + # + # CHECK biblionumber + # + # if ($biblionumbertagfield eq '001') { unless ($record->field($biblionumbertagfield) && $record->field($biblionumbertagfield)->data()) { $record_correct=0; @@ -623,6 +626,11 @@ rank:rank-1 } # warn "FIXED BIBLIONUMBER".$record->as_formatted; } + # + # + # CHECK BIBLIOITEMNUMBER + # + # unless ($record->subfield($biblioitemnumbertagfield,$biblioitemnumbertagsubfield)) { # warn "fixing biblioitemnumber for $biblioitemnumbertagfield,$biblioitemnumbertagsubfield = $biblionumber"; $record_correct=0; @@ -646,6 +654,11 @@ rank:rank-1 } # warn "FIXED BIBLIOITEMNUMBER".$record->as_formatted; } + # + # + # CHECK FIELD 100 + # + # my $encoding = C4::Context->preference("marcflavour"); # deal with UNIMARC field 100 (encoding) : create it if needed & set encoding to unicode if ( $encoding eq "UNIMARC" ) { @@ -661,7 +674,8 @@ rank:rank-1 $string = sprintf( "%-*s", 35, $string ); } substr( $string, 22, 6, "frey50" ); - unless ( $record->subfield( 100, "a" ) ) { + unless ( length($record->subfield( 100, "a" )) == 35 ) { + $record->delete_field($record->field(100)); $record->insert_grouped_field( MARC::Field->new( 100, "", "", "a" => $string ) ); } -- 2.39.5