From 25c514c3e10113eaf7937be767f5b37389daefdf Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sat, 2 Apr 2011 21:09:59 -0400 Subject: [PATCH] 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 Signed-off-by: Claire Hernandez Signed-off-by: Chris Cormack --- .../remove_items_from_biblioitems.pl | 61 +++++++++++++------ 1 file changed, 41 insertions(+), 20 deletions(-) mode change 100644 => 100755 misc/maintenance/remove_items_from_biblioitems.pl diff --git a/misc/maintenance/remove_items_from_biblioitems.pl b/misc/maintenance/remove_items_from_biblioitems.pl old mode 100644 new mode 100755 index 1a50f629de..0778b295ab --- a/misc/maintenance/remove_items_from_biblioitems.pl +++ b/misc/maintenance/remove_items_from_biblioitems.pl @@ -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_ } - -# -- 2.39.5