View | Details | Raw Unified | Return to bug 29325
Collapse All | Expand All

(-)a/C4/ImportBatch.pm (-1 / +11 lines)
Lines 571-576 sub BatchCommitRecords { Link Here
571
    my $batch_id = shift;
571
    my $batch_id = shift;
572
    my $framework = shift;
572
    my $framework = shift;
573
573
574
    my $schema = Koha::Database->schema;
575
574
    # optional callback to monitor status 
576
    # optional callback to monitor status 
575
    # of job
577
    # of job
576
    my $progress_interval = 0;
578
    my $progress_interval = 0;
Lines 612-620 sub BatchCommitRecords { Link Here
612
    my @biblio_ids;
614
    my @biblio_ids;
613
    while (my $rowref = $sth->fetchrow_hashref) {
615
    while (my $rowref = $sth->fetchrow_hashref) {
614
        $record_type = $rowref->{'record_type'};
616
        $record_type = $rowref->{'record_type'};
617
618
        # first record, begin transaction
619
        $schema->txn_begin
620
            unless $rec_num;
621
615
        $rec_num++;
622
        $rec_num++;
623
616
        if ($progress_interval and (0 == ($rec_num % $progress_interval))) {
624
        if ($progress_interval and (0 == ($rec_num % $progress_interval))) {
617
            &$progress_callback($rec_num);
625
            # report progress and commit
626
            &$progress_callback($rec_num, $schema);
627
            $schema->txn_begin;
618
        }
628
        }
619
        if ($rowref->{'status'} eq 'error' or $rowref->{'status'} eq 'imported') {
629
        if ($rowref->{'status'} eq 'error' or $rowref->{'status'} eq 'imported') {
620
            $num_ignored++;
630
            $num_ignored++;
(-)a/misc/commit_file.pl (-8 / +10 lines)
Lines 1-7 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use strict;
3
use Modern::Perl;
4
use warnings;
4
5
BEGIN {
6
    # find Koha's Perl modules
7
    # test carefully before changing this
8
    use FindBin ();
9
    eval { require "$FindBin::Bin/kohalib.pl" };
10
}
5
11
6
use Koha::Script;
12
use Koha::Script;
7
use C4::Context;
13
use C4::Context;
Lines 39-46 if ($list_batches) { Link Here
39
# in future, probably should tie to a real user account
45
# in future, probably should tie to a real user account
40
C4::Context->set_userenv(0, 'batch', 0, 'batch', 'batch', 'batch', 'batch');
46
C4::Context->set_userenv(0, 'batch', 0, 'batch', 'batch', 'batch', 'batch');
41
47
42
my $dbh = C4::Context->dbh;
43
$dbh->{AutoCommit} = 0;
44
if ($batch_number =~ /^\d+$/ and $batch_number > 0) {
48
if ($batch_number =~ /^\d+$/ and $batch_number > 0) {
45
    my $batch = GetImportBatch($batch_number);
49
    my $batch = GetImportBatch($batch_number);
46
    die "$0: import batch $batch_number does not exist in database\n" unless defined $batch;
50
    die "$0: import batch $batch_number does not exist in database\n" unless defined $batch;
Lines 53-59 if ($batch_number =~ /^\d+$/ and $batch_number > 0) { Link Here
53
            unless $batch->{'import_status'} eq "staged" or $batch->{'import_status'} eq "reverted";
57
            unless $batch->{'import_status'} eq "staged" or $batch->{'import_status'} eq "reverted";
54
        process_batch($batch_number);
58
        process_batch($batch_number);
55
    }
59
    }
56
    $dbh->commit();
57
} else {
60
} else {
58
    die "$0: please specify a numeric batch ID\n";
61
    die "$0: please specify a numeric batch ID\n";
59
}
62
}
Lines 124-132 _SUMMARY_ Link Here
124
127
125
128
126
sub print_progress_and_commit {
129
sub print_progress_and_commit {
127
    my $recs = shift;
130
    my ( $recs, $schema ) = @_;
128
    print "... processed $recs records\n";
131
    print "... processed $recs records\n";
129
    $dbh->commit();
132
    $schema->txn_commit;
130
}
133
}
131
134
132
sub print_usage {
135
sub print_usage {
133
- 

Return to bug 29325