From 99f1a3c53e85691103a9bc6c84d88d4ce1d64510 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 14 Oct 2016 14:27:15 +0200 Subject: [PATCH] Bug 17447: Remove unused vars from batchRebuildItemsTables.pl Variables $extkey not used, %opt not used. Variables $tmptest[...] not used, calling _build_tag_directory useless. The script now does not only print help if you specify -t. Sub defnonull tidied. Rearranged modules, removed Dumper. Test plan: [1] Run the script with -t flag. The script should not only print usage statement, but should do a dry run. (Test this on a small database, or pass an additional where clause.) Signed-off-by: Marcel de Rooy Signed-off-by: Mark Tompsett Signed-off-by: Kyle M Hall --- misc/batchRebuildItemsTables.pl | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/misc/batchRebuildItemsTables.pl b/misc/batchRebuildItemsTables.pl index eb9ce08..a18e321 100755 --- a/misc/batchRebuildItemsTables.pl +++ b/misc/batchRebuildItemsTables.pl @@ -1,14 +1,16 @@ #!/usr/bin/perl + use Modern::Perl; + use Getopt::Long; +use MARC::Field; +use MARC::Record; +use Pod::Usage; +use Time::HiRes qw(gettimeofday); + use C4::Context; use C4::Biblio; use C4::Items; -use MARC::Record; -use MARC::Field; -use Data::Dumper; -use Time::HiRes qw(gettimeofday); -use Pod::Usage; =head1 NAME @@ -41,7 +43,7 @@ GetOptions( 'where:s' => \$where, ) or pod2usage(2); -pod2usage(1) if ( $help || ( !$confirm ) ); +pod2usage(1) if $help || ( !$confirm && !$test_parameter ); print "### Database will not be modified ###\n" if $test_parameter; #dbh @@ -68,12 +70,9 @@ $sth->execute(); while ( my ( $biblionumber, $biblioitemnumber, $frameworkcode ) = $sth->fetchrow ) { $count++; warn $count unless $count % 1000; - my $extkey; my $record = GetMarcBiblio( $biblionumber, 1 ); unless ($record) { push @errors, "bad record biblionumber $biblionumber"; next; } - my ( $tmptestfields, $tmptestdirectory, $reclen, $tmptestbaseaddress ) = MARC::File::USMARC::_build_tag_directory($record); - #print "\n################################ record before ##################################\n".$record->as_formatted;#!test unless ($test_parameter) { my $rqitemnumber = $dbh->prepare("SELECT itemnumber, biblionumber from items where itemnumber = ? and biblionumber = ?"); foreach my $itemfield ( $record->field($itemfield) ) { @@ -109,5 +108,7 @@ if ( scalar(@errors) > 0 ) { print "Some biblionumber could not be processed though: ", join( " ", @errors ); } -sub defnonull { my $var = shift; defined $var and $var ne "" } -__END__ +sub defnonull { + my $var = shift; + defined $var and $var ne ""; +} -- 2.1.4