Koha/misc/migration_tools/22_to_30/rebuild_leader.pl
Jonathan Druart 238fabc4ab Bug 28617: Remove kohalib.pl and rely on PERL5LIB
The purpose of this script was to load the relevant Koha lib for the
different scripts (installation, cronjob, CLI, etc.)
However it is not used consistently and we prefer to rely on PERL5LIB.

From bug 28617 comment 6 from Galen:
"""
Time marches on, and one of the motivations for having kohalib.pl - making
it possible to install Koha without setting a single environment variable -
has been obviated by the vast improvements in the ease of installing Koha.

Consequently, I think kohalib.pl can go away.
"""

Test plan:
confirm that the changes make sense and that kohalib.pl can be removed
safely.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2021-12-07 12:16:28 -10:00

50 lines
1.1 KiB
Perl
Executable file

#!/usr/bin/perl
# This script finds and fixes missing 090 fields in Koha for MARC21
# Written by TG on 01/10/2005
# Revised by Joshua Ferraro on 03/31/2006
use strict;
#use warnings; FIXME - Bug 2505
# Koha modules used
use C4::Context;
use C4::Biblio qw( ModBiblioMarc );
use MARC::File::USMARC;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select m.bibid,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 = MARCgetbiblio($dbh,$biblionumber);
MARCmodleader($biblionumber,$record);
}
sub MARCmodleader{
my ($biblionumber,$record)=@_;
my $update=0;
#warn "".$record->leader();
#if (length($record->leader())>24){
# $record->leader(substr($record->leader,0,24));
# $update =1;
#} elsif (length($record->leader())<24){
$record->leader(' nac 22 1u 4500');
$update=1;
#}
warn "leader : ".$record->leader if ($biblionumber==2262);
foreach ($record->field('995')) {
$record->delete_field($_);
}
if ($update){
&ModBiblioMarc($record,$biblionumber);
print "$biblionumber \n";
}
}
END;