@@ -, +, @@ - In Staff interface Tools - Go to "Stage MARC records for import" - Import a marc records file with several records - Click on "Manage staged records" - Click on "Import this batch into the catalog" - Click on "Undo import into catalog" --- tools/manage-marc-import.pl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/tools/manage-marc-import.pl +++ a/tools/manage-marc-import.pl @@ -61,7 +61,6 @@ my ($template, $loggedinuser, $cookie) my %cookies = parse CGI::Cookie($cookie); our $sessionID = $cookies{'CGISESSID'}->value; -our $dbh = C4::Context->dbh; my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] }); $template->param( frameworks => $frameworks ); @@ -233,11 +232,13 @@ sub import_batches_list { sub commit_batch { my ($template, $import_batch_id, $framework) = @_; - my $job = undef; + # Use a DB transaction + my $dbh = C4::Context->dbh({new => 1}); $dbh->{AutoCommit} = 0; + my $job = undef; my $callback = sub {}; if ($runinbackground) { - $job = put_in_background($import_batch_id); + $job = put_in_background($import_batch_id, $dbh); $callback = progress_callback($job, $dbh); } my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) = @@ -263,11 +264,13 @@ sub commit_batch { sub revert_batch { my ($template, $import_batch_id) = @_; + # Use a DB transaction + my $dbh = C4::Context->dbh({new => 1}); $dbh->{AutoCommit} = 0; my $job = undef; my $callback = sub {}; if ($runinbackground) { - $job = put_in_background($import_batch_id); + $job = put_in_background($import_batch_id, $dbh); $callback = progress_callback($job, $dbh); } my ($num_deleted, $num_errors, $num_reverted, $num_items_deleted, $num_ignored) = @@ -291,6 +294,7 @@ sub revert_batch { sub put_in_background { my $import_batch_id = shift; + my $dbh = shift; my $batch = GetImportBatch($import_batch_id); my $job = C4::BackgroundJob->new($sessionID, $batch->{'file_name'}, '/cgi-bin/koha/tools/manage-marc-import.pl', $batch->{'num_records'}); --