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

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

Return to bug 29325