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

(-)a/C4/ImportBatch.pm (-1 / +11 lines)
Lines 540-545 sub BatchCommitRecords { Link Here
540
    my $batch_id = shift;
540
    my $batch_id = shift;
541
    my $framework = shift;
541
    my $framework = shift;
542
542
543
    my $schema = Koha::Database->schema;
544
543
    # optional callback to monitor status 
545
    # optional callback to monitor status 
544
    # of job
546
    # of job
545
    my $progress_interval = 0;
547
    my $progress_interval = 0;
Lines 580-588 sub BatchCommitRecords { Link Here
580
    my $rec_num = 0;
582
    my $rec_num = 0;
581
    while (my $rowref = $sth->fetchrow_hashref) {
583
    while (my $rowref = $sth->fetchrow_hashref) {
582
        $record_type = $rowref->{'record_type'};
584
        $record_type = $rowref->{'record_type'};
585
586
        # first record, begin transaction
587
        $schema->txn_begin
588
            unless $rec_num;
589
583
        $rec_num++;
590
        $rec_num++;
591
584
        if ($progress_interval and (0 == ($rec_num % $progress_interval))) {
592
        if ($progress_interval and (0 == ($rec_num % $progress_interval))) {
585
            &$progress_callback($rec_num);
593
            # report progress and commit
594
            &$progress_callback($rec_num, $schema);
595
            $schema->txn_begin;
586
        }
596
        }
587
        if ($rowref->{'status'} eq 'error' or $rowref->{'status'} eq 'imported') {
597
        if ($rowref->{'status'} eq 'error' or $rowref->{'status'} eq 'imported') {
588
            $num_ignored++;
598
            $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