X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=tools%2Fmanage-marc-import.pl;h=892ffe8b95e4b61dc1763c1e5b6b064fa1aaeb4d;hb=3db0401366b8e099ab2046d68cf20a9f754e1eae;hp=83abc91513ec0679e04501b5acdacde182e4e5f9;hpb=08e448ee4bfbd7a85dfbfd6d0d77f8d59dd93b8e;p=srvgit diff --git a/tools/manage-marc-import.pl b/tools/manage-marc-import.pl index 83abc91513..892ffe8b95 100755 --- a/tools/manage-marc-import.pl +++ b/tools/manage-marc-import.pl @@ -36,6 +36,7 @@ use C4::ImportBatch; use C4::Matcher; use C4::BackgroundJob; use C4::Labels::Batch; +use Koha::BiblioFrameworks; my $script_name = "/cgi-bin/koha/tools/manage-marc-import.pl"; @@ -62,15 +63,8 @@ my %cookies = parse CGI::Cookie($cookie); our $sessionID = $cookies{'CGISESSID'}->value; our $dbh = C4::Context->dbh; -# Frameworks selection loop -{ - my $frameworks = getframeworks; - my $arrayref = []; - while ( my ($key, $value) = each %$frameworks ) { - push @$arrayref, { value => $key, label => $value->{frameworktext} }; - } - $template->param( frameworks => $arrayref ); -} +my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] }); +$template->param( frameworks => $frameworks ); if ($op eq "create_labels") { #create a batch of labels, then lose $op & $import_batch_id so we get back to import batch list. @@ -240,15 +234,24 @@ sub commit_batch { my ($template, $import_batch_id, $framework) = @_; my $job = undef; - $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 ); + } + ); my $results = { did_commit => 1, @@ -269,16 +272,25 @@ sub commit_batch { sub revert_batch { my ($template, $import_batch_id) = @_; - $dbh->{AutoCommit} = 0; my $job = undef; - my $callback = sub {}; - if ($runinbackground) { - $job = put_in_background($import_batch_id); - $callback = progress_callback($job, $dbh); - } - my ($num_deleted, $num_errors, $num_reverted, $num_items_deleted, $num_ignored) = - BatchRevertRecords($import_batch_id, 50, $callback); - $dbh->commit(); + my ( + $num_deleted, $num_errors, $num_reverted, + $num_items_deleted, $num_ignored + ); + my $schema = Koha::Database->new->schema; + $schema->txn_do( + sub { + my $callback = sub { }; + if ($runinbackground) { + $job = put_in_background($import_batch_id); + $callback = progress_callback( $job, $dbh ); + } + ( + $num_deleted, $num_errors, $num_reverted, + $num_items_deleted, $num_ignored + ) = BatchRevertRecords( $import_batch_id, 50, $callback ); + } + ); my $results = { did_revert => 1,