X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=misc%2Fcommit_biblios_file.pl;h=b4be670396f2524f3145852d5da55d3d7de13b97;hb=48cc802e46d09c9b1acd4b13105fefab88acbe18;hp=f0cbd06d3e6bd91ce50e517de496be38cba8551b;hpb=ad4e02f91d3c18e7705f5c6f58006ebf3e676613;p=koha_fer diff --git a/misc/commit_biblios_file.pl b/misc/commit_biblios_file.pl index f0cbd06d3e..b4be670396 100755 --- a/misc/commit_biblios_file.pl +++ b/misc/commit_biblios_file.pl @@ -1,6 +1,13 @@ #!/usr/bin/perl use strict; +#use warnings; FIXME - Bug 2505 +BEGIN { + # find Koha's Perl modules + # test carefully before changing this + use FindBin; + eval { require "$FindBin::Bin/kohalib.pl" }; +} use C4::Context; use C4::ImportBatch; @@ -33,12 +40,15 @@ if ($list_batches) { # in future, probably should tie to a real user account C4::Context->set_userenv(0, 'batch', 0, 'batch', 'batch', 'batch', 'batch', 'batch'); +my $dbh = C4::Context->dbh; +$dbh->{AutoCommit} = 0; if ($batch_number =~ /^\d+$/ and $batch_number > 0) { my $batch = GetImportBatch($batch_number); die "$0: import batch $batch_number does not exist in database\n" unless defined $batch; die "$0: import batch $batch_number status is '" . $batch->{'import_status'} . "', and therefore cannot be imported\n" unless $batch->{'import_status'} eq "staged" or $batch->{'import_status'} eq "reverted"; process_batch($batch_number); + $dbh->commit(); } else { die "$0: please specify a numeric batch ID\n"; } @@ -65,7 +75,7 @@ sub process_batch { print "... importing MARC records -- please wait\n"; my ($num_added, $num_updated, $num_items_added, $num_items_errored, $num_ignored) = - BatchCommitBibRecords($import_batch_id, 100, \&print_progress); + BatchCommitBibRecords($import_batch_id, '', 100, \&print_progress_and_commit); print "... finished importing MARC records\n"; print <<_SUMMARY_; @@ -84,9 +94,10 @@ duplicate of one already in the database. _SUMMARY_ } -sub print_progress { +sub print_progress_and_commit { my $recs = shift; print "... processed $recs records\n"; + $dbh->commit(); } sub print_usage {