From ea7aabe77a93805cc683753b6fd237967df9ec09 Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Sat, 18 Apr 2009 21:58:32 +0200 Subject: [PATCH] Repair the old repairmissingbiblionumbers script This patch refound all the script which fix all records without any biblionumber. Signed-off-by: Galen Charlton Signed-off-by: Henri-Damien LAURENT --- misc/batchRepairMissingBiblionumbers.pl | 50 ++++++++----------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/misc/batchRepairMissingBiblionumbers.pl b/misc/batchRepairMissingBiblionumbers.pl index 920f593e21..3b3c345d42 100755 --- a/misc/batchRepairMissingBiblionumbers.pl +++ b/misc/batchRepairMissingBiblionumbers.pl @@ -3,6 +3,7 @@ # Written by TG on 01/10/2005 # Revised by Joshua Ferraro on 03/31/2006 use strict; +use warnings; BEGIN { # find Koha's Perl modules # test carefully before changing this @@ -14,43 +15,24 @@ BEGIN { use C4::Context; use C4::Biblio; -use MARC::Record; -use MARC::File::USMARC; my $dbh = C4::Context->dbh; - -my $sth=$dbh->prepare("select m.biblionumber,b.biblioitemnumber from marc_biblio m left join biblioitems b on b.biblionumber=m.biblionumber "); - $sth->execute(); - -while (my ($biblionumber,$biblioitemnumber)=$sth->fetchrow ){ - my $record = GetMarcBiblio($biblionumber); - - MARCmodbiblionumber($biblionumber,$biblioitemnumber,$record); - -} - -sub MARCmodbiblionumber{ -my ($biblionumber,$biblioitemnumber,$record)=@_; - -my ($tagfield,$biblionumtagsubfield) = &GetMarcFromKohaField("biblio.biblionumber",""); -my ($tagfield2,$biblioitemtagsubfield) = &GetMarcFromKohaField("biblio.biblioitemnumber",""); - -my $update=0; - my @tags = $record->field($tagfield); - -if (!@tags){ - -my $newrec = MARC::Field->new( $tagfield,'','', $biblionumtagsubfield => $biblionumber,$biblioitemtagsubfield=>$biblioitemnumber); - $record->append_fields($newrec); - $update=1; - } - - -if ($update){ -&ModBiblioMarc($record,'',$biblionumber); - print "$biblionumber \n"; +my %kohafields; + +my $sth=$dbh->prepare("SELECT biblio.biblionumber, biblioitemnumber, frameworkcode FROM biblio JOIN biblioitems USING (biblionumber)"); +$sth->execute(); + +while (my ($biblionumber,$biblioitemnumber,$frameworkcode)=$sth->fetchrow ){ + my $record = GetMarcBiblio($biblionumber); + C4::Biblio::_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber); + my $biblionumber = eval {ModBiblioMarc( $record, $biblionumber, $frameworkcode )}; + if($@){ + print "Problem with biblionumber : $biblionumber\n"; + exit -1; + }else{ + print "biblionumber : $biblionumber\r\r"; } - } + END; -- 2.39.5