Koha/misc/maintenance/remove_items_from_biblioitems.pl
Henri-Damien LAURENT 3584c4426b Bug 5579: remove items from MARC bib
This is a squash of four patches by Henri-Damien Laurent
starting work on removing the copy of item record information
in the 9XX field of bibliographic records.  The reason
for doing this is primarily to improve performance, in particular,
the expense of having to add/modify the bib record whenever an
item changes.  Now, whenever an item changes, the bib record is
put in the queue to be reindexed; when the bib is indexed, the 9XX
fields are inserted into the version of the bib that Zebra indexes.
Since rebuild_zebra.pl runs in a separate process, the processing of the
bib record will not delay (e.g.) circulation.

As part of upgrading to 3.4, the following batch script should be run:

misc/maintenance/remove_items_from_biblioitems.pl --run

This should be followed by a complete reindexing of the bib records, e.g.,

misc/migration_tools/rebuild_zebra.pl -b -r

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
2011-04-19 22:33:56 +12:00

50 lines
1.1 KiB
Perl

#!/usr/bin/perl
use strict;
use warnings;
use C4::Context;
use C4::Biblio;
use Getopt::Long;
my ($wherestring,$run,$want_help);
my $result = GetOptions(
'where:s' => \$wherestring,
'--run' => \$run,
'help|h' => \$want_help,
);
if ( not $result or $want_help ) {
print_usage();
exit 0;
}
my $dbh=C4::Context->dbh;
my $querysth=qq{SELECT biblionumber from biblioitems };
$querysth.=" WHERE $wherestring " if ($wherestring);
my $query=$dbh->prepare($querysth);
$query->execute;
while (my $biblionumber=$query->fetchrow){
my $record=GetMarcBiblio($biblionumber);
if ($record){
ModBiblio($record,$biblionumber,GetFrameworkCode($biblionumber)) ;
}
else {
print "error in $biblionumber : can't parse biblio";
}
}
sub print_usage {
print <<_USAGE_;
$0: removes items from selected biblios
Parameters:
-where use this to limit modifications to some biblios
--run run the command
--help or -h show this message.
_USAGE_
}
#