From 13bf7f1b7d24e4ba9fcd1b1e7684f512ff5be781 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 Signed-off-by: Tomas Cohen Arazi (cherry picked from commit a3a58b93c3d1c78153dec8a3e5849561f7cf6607) Signed-off-by: Martin Renvoize --- 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 c80c469dd7..f7cd876d26 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.39.5