From 6198b5033e6a279eab57a2f275b880136faa1dee Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 24 Jun 2021 15:11:18 +0200 Subject: [PATCH] Bug 28399: Remove txn error from batchRebuildItemsTables.pl Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit f131e51984898f689281b8adb3ead7c33168e00b) Signed-off-by: Fridolin Somers --- misc/batchRebuildItemsTables.pl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/misc/batchRebuildItemsTables.pl b/misc/batchRebuildItemsTables.pl index 5bb40e5d35..58630cbded 100755 --- a/misc/batchRebuildItemsTables.pl +++ b/misc/batchRebuildItemsTables.pl @@ -46,9 +46,9 @@ GetOptions( pod2usage(1) if $help || ( !$confirm && !$test_parameter ); print "### Database will not be modified ###\n" if $test_parameter; -#dbh my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; +my $schema = Koha::Database->schema; +$schema->txn_begin; #sysprefs C4::Context->disable_syspref_cache() if ( defined( C4::Context->disable_syspref_cache() ) ); @@ -56,7 +56,10 @@ my $CataloguingLog = C4::Context->preference('CataloguingLog'); my $mergelimit = C4::Context->preference('AuthorityMergeLimit'); $dbh->do("UPDATE systempreferences SET value=0 WHERE variable='CataloguingLog'"); $dbh->do("UPDATE systempreferences SET value=0 where variable='AuthorityMergeLimit'"); -$dbh->commit() unless $test_parameter; +unless ($test_parameter){ + $schema->txn_commit; + $schema->txn_begin; +} my ( $itemfield, $itemnumbersubfield ) = &GetMarcFromKohaField( "items.itemnumber" ); #dbh query init @@ -93,8 +96,10 @@ while ( my ( $biblionumber, $biblioitemnumber, $frameworkcode ) = $sth->fetchrow if ($@) { warn "Problem with : $biblionumber : $@"; warn $record->as_formatted; } } } - unless ($test_parameter) { - $dbh->commit() unless $count % 1000; + + unless ($test_parameter || $count % 1000) { + $schema->txn_commit; + $schema->txn_begin; } } @@ -102,7 +107,7 @@ my $sthCataloguingLog = $dbh->prepare("UPDATE systempreferences SET value=? WHER $sthCataloguingLog->execute($CataloguingLog); my $sthmergelimit = $dbh->prepare("UPDATE systempreferences SET value=? WHERE variable='AuthorityMergeLimit'"); $sthmergelimit->execute($mergelimit); -$dbh->commit() unless $test_parameter; +$schema->txn_commit unless $test_parameter; my $timeneeded = time() - $starttime; print "$count MARC record done in $timeneeded seconds\n"; if ( scalar(@errors) > 0 ) { -- 2.39.5