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

(-)a/tools/manage-marc-import.pl (-5 / +8 lines)
Lines 61-67 my ($template, $loggedinuser, $cookie) Link Here
61
61
62
my %cookies = parse CGI::Cookie($cookie);
62
my %cookies = parse CGI::Cookie($cookie);
63
our $sessionID = $cookies{'CGISESSID'}->value;
63
our $sessionID = $cookies{'CGISESSID'}->value;
64
our $dbh = C4::Context->dbh;
65
64
66
my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
65
my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
67
$template->param( frameworks => $frameworks );
66
$template->param( frameworks => $frameworks );
Lines 233-243 sub import_batches_list { Link Here
233
sub commit_batch {
232
sub commit_batch {
234
    my ($template, $import_batch_id, $framework) = @_;
233
    my ($template, $import_batch_id, $framework) = @_;
235
234
236
    my $job = undef;
235
    # Use a DB transaction
236
    my $dbh = C4::Context->dbh({new => 1});
237
    $dbh->{AutoCommit} = 0;
237
    $dbh->{AutoCommit} = 0;
238
    my $job = undef;
238
    my $callback = sub {};
239
    my $callback = sub {};
239
    if ($runinbackground) {
240
    if ($runinbackground) {
240
        $job = put_in_background($import_batch_id);
241
        $job = put_in_background($import_batch_id, $dbh);
241
        $callback = progress_callback($job, $dbh);
242
        $callback = progress_callback($job, $dbh);
242
    }
243
    }
243
    my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) =
244
    my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) =
Lines 263-273 sub commit_batch { Link Here
263
sub revert_batch {
264
sub revert_batch {
264
    my ($template, $import_batch_id) = @_;
265
    my ($template, $import_batch_id) = @_;
265
266
267
    # Use a DB transaction
268
    my $dbh = C4::Context->dbh({new => 1});
266
    $dbh->{AutoCommit} = 0;
269
    $dbh->{AutoCommit} = 0;
267
    my $job = undef;
270
    my $job = undef;
268
    my $callback = sub {};
271
    my $callback = sub {};
269
    if ($runinbackground) {
272
    if ($runinbackground) {
270
        $job = put_in_background($import_batch_id);
273
        $job = put_in_background($import_batch_id, $dbh);
271
        $callback = progress_callback($job, $dbh);
274
        $callback = progress_callback($job, $dbh);
272
    }
275
    }
273
    my ($num_deleted, $num_errors, $num_reverted, $num_items_deleted, $num_ignored) = 
276
    my ($num_deleted, $num_errors, $num_reverted, $num_items_deleted, $num_ignored) = 
Lines 291-296 sub revert_batch { Link Here
291
294
292
sub put_in_background {
295
sub put_in_background {
293
    my $import_batch_id = shift;
296
    my $import_batch_id = shift;
297
    my $dbh = shift;
294
298
295
    my $batch = GetImportBatch($import_batch_id);
299
    my $batch = GetImportBatch($import_batch_id);
296
    my $job = C4::BackgroundJob->new($sessionID, $batch->{'file_name'}, '/cgi-bin/koha/tools/manage-marc-import.pl', $batch->{'num_records'});
300
    my $job = C4::BackgroundJob->new($sessionID, $batch->{'file_name'}, '/cgi-bin/koha/tools/manage-marc-import.pl', $batch->{'num_records'});
297
- 

Return to bug 18343