bug 5579: improvements to remove_items_from_biblioitems.pl

* add copyright statement
* make --run switch work; this is now required to cause
  the update to run
* improve help text
* make remove_items_from_biblioitems.pl executable

Signed-off-by: Galen Charlton <gmcharlt@esilibrary.com>
Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
Galen Charlton 2011-04-02 21:09:59 -04:00 committed by Chris Cormack
parent 3584c4426b
commit 25c514c3e1

61
misc/maintenance/remove_items_from_biblioitems.pl Normal file → Executable file
View file

@ -1,5 +1,23 @@
#!/usr/bin/perl
# Copyright 2010 BibLibre
# Copyright 2011 Equinox Software, Inc.
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
use warnings;
@ -7,44 +25,47 @@ use C4::Context;
use C4::Biblio;
use Getopt::Long;
my ($wherestring,$run,$want_help);
my $result = GetOptions(
'where:s' => \$wherestring,
my ($wherestring, $run, $want_help);
my $result = GetOptions(
'where:s' => \$wherestring,
'--run' => \$run,
'help|h' => \$want_help,
'help|h' => \$want_help,
);
if ( not $result or $want_help ) {
if ( not $result or not $run 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);
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);
while (my $biblionumber = $query->fetchrow){
my $record = GetMarcBiblio($biblionumber);
if ($record){
ModBiblio($record,$biblionumber,GetFrameworkCode($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
This utility is meant to be run as part of the upgrade to
Koha 3.4. It removes the 9XX fields in the bib records that
store a (now) duplicate copy of the item record information. After
running this utility, a full reindexing of the bibliographic records
should be run using rebuild_zebra.pl -b -r.
Parameters:
-where use this to limit modifications to some biblios
--run run the command
--help or -h show this message.
-where use this to limit modifications to selected biblios
--run perform the update
--help or -h show this message
_USAGE_
}
#