Koha/misc/batchRepairMissingBiblionumbers.pl
Jonathan Druart 70d61d80fb
Bug 29697: Replace GetMarcBiblio occurrences with $biblio->metadata->record
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

JD Amended patch:
-# FIXME Special case here

-    print "Biblio not found\n,";
+    print "Biblio not found\n";

- my $biblio = Koha::Biblio->find($hostbiblionumber);
+ my $biblio = Koha::Biblios->find($hostbiblionumber);

Rebased-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-07-22 15:24:11 -03:00

33 lines
1,007 B
Perl
Executable file

#!/usr/bin/perl
# This script finds and fixes missing biblionumber/biblioitemnumber fields in Koha
# Written by TG on 01/10/2005
# Revised by Joshua Ferraro on 03/31/2006
use strict;
use warnings;
# Koha modules used
use Koha::Script;
use C4::Context;
use C4::Biblio qw( ModBiblioMarc );
use Koha::Biblios;
my $dbh = C4::Context->dbh;
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 $biblio = Koha::Biblios->find($biblionumber);
my $record = $biblio->metadata->record;
C4::Biblio::_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber);
my $biblionumber = eval {ModBiblioMarc( $record, $biblionumber )};
if($@){
print "Problem with biblionumber : $biblionumber\n";
exit -1;
}else{
print "biblionumber : $biblionumber\r\r";
}
}
END;