X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=misc%2FbatchRebuildBiblioTables.pl;h=ae4f54eab28fd374d8de3d3c06ffcf2fdde69437;hb=f47ad12f9de2c046c3a97440238dcc65570b1f68;hp=5102bd57657aa723ae3d3a540587744104fcb682;hpb=8c60e8260583e0b20384d29a2d45cd2a2b2ba686;p=koha.git diff --git a/misc/batchRebuildBiblioTables.pl b/misc/batchRebuildBiblioTables.pl index 5102bd5765..ae4f54eab2 100755 --- a/misc/batchRebuildBiblioTables.pl +++ b/misc/batchRebuildBiblioTables.pl @@ -1,7 +1,10 @@ #!/usr/bin/perl -# small script that rebuilds the non-MARC DB +# Small script that rebuilds the non-MARC DB +# Formerly named rebuildnonmarc.pl use strict; +#use warnings; FIXME - Bug 2505 + BEGIN { # find Koha's Perl modules # test carefully before changing this @@ -10,16 +13,14 @@ BEGIN { } # Koha modules used -# use MARC::File::USMARC; use MARC::Record; -use MARC::Batch; use C4::Context; use C4::Biblio; use Time::HiRes qw(gettimeofday); use Getopt::Long; -my ( $input_marc_file, $number) = ('',0); -my ($version, $confirm,$test_parameter); +my ( $input_marc_file, $number) = ('', 0); +my ($version, $confirm, $test_parameter); GetOptions( 'c' => \$confirm, 'h' => \$version, @@ -30,15 +31,17 @@ if ($version || (!$confirm)) { print < shows this screen) -\t./rebuildnonmarc.pl -c (c like confirm => rebuild non marc DB (may be long) + +Example: you decide to map biblio.title to 200\$a (it was previously mapped to 610\$a). +Run this script or you will have strange results in OPAC ! + +Syntax: +\t./batchRebuildBiblioTables.pl -h (or without arguments => shows this screen) +\t./batchRebuildBiblioTables.pl -c (c like confirm => rebuild non marc DB (may be long) \t-t => test only, change nothing in DB EOF ; -die; + exit; } my $dbh = C4::Context->dbh; @@ -55,9 +58,14 @@ my $sth = $dbh->prepare("SELECT biblionumber FROM biblio"); $sth->execute; # my ($biblionumbermax) = $sth->fetchrow; # warn "$biblionumbermax <<=="; +my @errors; while (my ($biblionumber)= $sth->fetchrow) { #now, parse the record, extract the item fields, and store them in somewhere else. my $record = GetMarcBiblio($biblionumber); + if (not defined $record) { + push @errors, $biblionumber; + next; + } my @fields = $record->field($tagfield); my @items; my $nbitems=0; @@ -79,6 +87,9 @@ while (my ($biblionumber)= $sth->fetchrow) { # $dbh->do("unlock tables"); my $timeneeded = time() - $starttime; print "$i MARC record done in $timeneeded seconds\n"; +if (scalar(@errors) > 0) { + print "Some biblionumber could not be processed though: ", join(" ", @errors); +} # modified NEWmodbiblio to jump the MARC part of the biblio modif # highly faster @@ -86,7 +97,7 @@ sub localNEWmodbiblio { my ($dbh,$record,$biblionumber,$frameworkcode) =@_; $frameworkcode="" unless $frameworkcode; my $oldbiblio = TransformMarcToKoha($dbh,$record,$frameworkcode); - C4::Biblio::_koha_modify_biblio( $dbh, $oldbiblio ); + C4::Biblio::_koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode ); C4::Biblio::_koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio ); return 1; }