From 00aaa610fb71c7796145304590b7ecc63f189a13 Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Wed, 15 Dec 2010 20:45:24 +0100 Subject: [PATCH] Bug 5724: Handling deleted records better MT3915: rebuild_zebra changes because deleted biblios would stick in zebra indexes Since the update of biblios would be done AFTER the deletion of biblios, and since biblios would be updated just before being deleted (in order to delete the items) update process would recreate the biblio. This patch fixes the order in order to do the deletion AFTER the update. --- misc/migration_tools/rebuild_zebra.pl | 25 +++++++++++-------------- 1 files changed, 11 insertions(+), 14 deletions(-) diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl index dadf43f..7a998f8 100755 --- a/misc/migration_tools/rebuild_zebra.pl +++ b/misc/migration_tools/rebuild_zebra.pl @@ -66,12 +66,6 @@ if (not $biblios and not $authorities) { die $msg; } -if ($authorities and $as_xml) { - my $msg = "Cannot specify both -a and -x\n"; - $msg .= "Please do '$0 --help' to see usage.\n"; - die $msg; -} - if ( !$as_xml and $nosanitize ) { my $msg = "Cannot specify both -no_xml and -nosanitize\n"; $msg .= "Please do '$0 --help' to see usage.\n"; @@ -238,10 +232,10 @@ sub index_records { } my $record_fmt = ($as_xml) ? 'marcxml' : 'iso2709' ; if ($process_zebraqueue) { - do_indexing($record_type, 'delete', "$directory/del_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt) - if %$records_deleted; do_indexing($record_type, 'update', "$directory/upd_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt) if $num_records_exported; + do_indexing($record_type, 'delete', "$directory/del_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt) + if %$records_deleted; } else { do_indexing($record_type, 'update', "$directory/$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt) if ($num_records_exported or $skip_export); @@ -453,7 +447,8 @@ sub get_raw_marc_record { my $marc; if ($record_type eq 'biblio') { if ($noxml) { - my $fetch_sth = $dbh->prepare_cached("SELECT marc FROM biblioitems WHERE biblionumber = ?"); + my $fetch_sth = $dbh->prepare_cached("SELECT marc FROM biblioitems WHERE biblionumber = ? + UNION SELECT marc from deletedbiblioitems where biblionumber=?"); $fetch_sth->execute($record_number); if (my ($blob) = $fetch_sth->fetchrow_array) { $marc = MARC::Record->new_from_usmarc($blob); @@ -468,7 +463,7 @@ sub get_raw_marc_record { $fetch_sth->finish(); return unless $marc; } else { - eval { $marc = GetMarcBiblio($record_number); }; + eval { $marc = GetMarcBiblio($record_number,"include_deleted_table"); }; if ($@ || !$marc) { # here we do warn since catching an exception # means that the bib was found but failed @@ -486,7 +481,7 @@ sub get_raw_marc_record { return; } } - return $marc; + return $marc; } sub fix_leader { @@ -514,10 +509,11 @@ sub fix_biblio_ids { my $biblioitemnumber; if (@_) { $biblioitemnumber = shift; - } else { + } else { my $sth = $dbh->prepare( - "SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); - $sth->execute($biblionumber); + "SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=? + UNION SELECT biblioitemnumber FROM deletedbiblioitems WHERE biblionumber=?"); + $sth->execute($biblionumber,$biblionumber); ($biblioitemnumber) = $sth->fetchrow_array; $sth->finish; unless ($biblioitemnumber) { @@ -550,6 +546,7 @@ sub fix_authority_id { } } + sub fix_unimarc_100 { # FIXME - again, if this is necessary, it belongs in C4::AuthoritiesMarc. my $marc = shift; -- 1.7.4.1