From 5e080b9a2e61366790839a6811df45a64e21d098 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 26 Apr 2023 12:50:03 +0000 Subject: [PATCH] Bug 32250: (follow-up) Remove use of AutoCommit=0 This patch moves to using txn_begin and txn_commit Signed-off-by: Jonathan Druart Bug 32250: (follow-up) Remove one more dbh commit and don't start a new transaction when done Signed-off-by: Jonathan Druart --- misc/link_bibs_to_authorities.pl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/misc/link_bibs_to_authorities.pl b/misc/link_bibs_to_authorities.pl index c80c469dd76..f7cd876d26e 100755 --- a/misc/link_bibs_to_authorities.pl +++ b/misc/link_bibs_to_authorities.pl @@ -17,6 +17,7 @@ use Time::HiRes qw( time ); use POSIX qw( ceil strftime ); use Module::Load::Conditional qw( can_load ); +use Koha::Database; use Koha::SearchEngine; use Koha::SearchEngine::Indexer; @@ -81,9 +82,9 @@ my $dbh = C4::Context->dbh; my @updated_biblios = (); my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); -$dbh->{AutoCommit} = 0; +my $schema = Koha::Database->schema; +$schema->txn_begin; process_bibs( $linker, $bib_limit, $auth_limit, $commit, { tagtolink => $tagtolink, allowrelink => $allowrelink }); -$dbh->commit(); exit 0; @@ -111,8 +112,7 @@ sub process_bibs { } if ( not $test_only ) { - $dbh->commit; - $dbh->{AutoCommit} = 1; + $schema->txn_commit; $indexer->index_records( \@updated_biblios, "specialUpdate", "biblioserver" ); } @@ -248,11 +248,10 @@ sub process_bib { sub print_progress_and_commit { my $recs = shift; - $dbh->commit(); - $dbh->{AutoCommit} = 1; + $schema->txn_commit(); $indexer->index_records( \@updated_biblios, "specialUpdate", "biblioserver" ); - $dbh->{AutoCommit} = 0; @updated_biblios = (); + $schema->txn_begin(); print "... processed $recs records\n"; } -- 2.25.1