Bug 32250: (follow-up) Remove use of AutoCommit=0

This patch moves to using txn_begin and txn_commit

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Bug 32250: (follow-up) Remove one more dbh commit and don't start a new transaction when done

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2023-04-26 12:50:03 +00:00 committed by Tomas Cohen Arazi
parent bfc1e3c226
commit a3a58b93c3
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 6 additions and 7 deletions

View File

@ -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";
}