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

(-)a/C4/ImportBatch.pm (-6 / +5 lines)
Lines 580-597 sub BatchCommitRecords { Link Here
580
    my $logged_in_patron = Koha::Patrons->find( $userenv->{number} );
580
    my $logged_in_patron = Koha::Patrons->find( $userenv->{number} );
581
581
582
    my $rec_num = 0;
582
    my $rec_num = 0;
583
    my @biblio_ids;
584
    $schema->txn_begin; # We commit in a transaction
583
    while (my $rowref = $sth->fetchrow_hashref) {
585
    while (my $rowref = $sth->fetchrow_hashref) {
584
        $record_type = $rowref->{'record_type'};
586
        $record_type = $rowref->{'record_type'};
585
587
586
        # first record, begin transaction
587
        $schema->txn_begin
588
            unless $rec_num;
589
590
        $rec_num++;
588
        $rec_num++;
591
589
592
        if ($progress_interval and (0 == ($rec_num % $progress_interval))) {
590
        if ($progress_interval and (0 == ($rec_num % $progress_interval))) {
593
            # report progress and commit
591
            # report progress and commit
594
            &$progress_callback($rec_num, $schema);
592
            $schema->txn_commit;
593
            &$progress_callback( $rec_num );
595
            $schema->txn_begin;
594
            $schema->txn_begin;
596
        }
595
        }
597
        if ($rowref->{'status'} eq 'error' or $rowref->{'status'} eq 'imported') {
596
        if ($rowref->{'status'} eq 'error' or $rowref->{'status'} eq 'imported') {
Lines 708-714 sub BatchCommitRecords { Link Here
708
            SetImportRecordStatus($rowref->{'import_record_id'}, 'ignored');
707
            SetImportRecordStatus($rowref->{'import_record_id'}, 'ignored');
709
        }
708
        }
710
    }
709
    }
711
    &$progress_callback($rec_num, $schema); # Make sure to commit the final chunk that didn't hit the commit threshhold
710
    $schema->txn_commit; # Commit final records that may not have hit callback threshhold
712
    $sth->finish();
711
    $sth->finish();
713
    SetImportBatchStatus($batch_id, 'imported');
712
    SetImportBatchStatus($batch_id, 'imported');
714
    return ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored);
713
    return ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored);
(-)a/misc/commit_file.pl (-1 lines)
Lines 129-135 _SUMMARY_ Link Here
129
sub print_progress_and_commit {
129
sub print_progress_and_commit {
130
    my ( $recs, $schema ) = @_;
130
    my ( $recs, $schema ) = @_;
131
    print "... processed $recs records\n";
131
    print "... processed $recs records\n";
132
    $schema->txn_commit;
133
}
132
}
134
133
135
sub print_usage {
134
sub print_usage {
(-)a/tools/manage-marc-import.pl (-4 / +1 lines)
Lines 277-283 sub revert_batch { Link Here
277
            my $callback = sub { };
277
            my $callback = sub { };
278
            if ($runinbackground) {
278
            if ($runinbackground) {
279
                $job = put_in_background($import_batch_id);
279
                $job = put_in_background($import_batch_id);
280
                $callback = progress_callback( $job, $dbh );
280
                $callback = progress_callback( $job );
281
            }
281
            }
282
            (
282
            (
283
                $num_deleted,       $num_errors, $num_reverted,
283
                $num_deleted,       $num_errors, $num_reverted,
Lines 345-353 sub progress_callback { Link Here
345
    my $job = shift;
345
    my $job = shift;
346
    return sub {
346
    return sub {
347
        my $progress = shift;
347
        my $progress = shift;
348
        my $schema = shift;
349
        $job->progress($progress);
348
        $job->progress($progress);
350
        $schema->txn_commit;
351
    }
349
    }
352
}
350
}
353
351
354
- 

Return to bug 29325