- $dbh->{AutoCommit} = 0;
- my $callback = sub {};
- if ($runinbackground) {
- $job = put_in_background($import_batch_id);
- $callback = progress_callback($job, $dbh);
- }
- my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) =
- BatchCommitRecords($import_batch_id, $framework, 50, $callback);
- $dbh->commit();
+ my ( $num_added, $num_updated, $num_items_added,
+ $num_items_replaced, $num_items_errored, $num_ignored );
+ my $schema = Koha::Database->new->schema;
+ $schema->storage->txn_do(
+ sub {
+ my $callback = sub { };
+ if ($runinbackground) {
+ $job = put_in_background($import_batch_id);
+ $callback = progress_callback( $job, $dbh );
+ }
+ (
+ $num_added, $num_updated, $num_items_added,
+ $num_items_replaced, $num_items_errored, $num_ignored
+ )
+ = BatchCommitRecords( $import_batch_id, $framework, 50,
+ $callback );
+ }
+ );