From 9038cdd9a45c06266b18167900fd428b0b1395ad Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 12 Oct 2020 15:01:22 +0200 Subject: [PATCH] Bug 26518: Move BiblioAutoLink within the transaction We don't want the authorities to be created if the biblio insert fails later Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- C4/Biblio.pm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 3fe8b38716..6e53842ee1 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -206,20 +206,19 @@ sub AddBiblio { $defer_marc_save = 1; } - if (C4::Context->preference('BiblioAddsAuthorities')) { - BiblioAutoLink( $record, $frameworkcode ); - } - - my ( $biblionumber, $biblioitemnumber, $error ); - my $dbh = C4::Context->dbh; - - # transform the data into koha-table style data - SetUTF8Flag($record); - my $olddata = TransformMarcToKoha( $record, $frameworkcode ); my $schema = Koha::Database->schema; + my ( $biblionumber, $biblioitemnumber ); try { $schema->txn_do(sub { + if (C4::Context->preference('BiblioAddsAuthorities')) { + BiblioAutoLink( $record, $frameworkcode ); + } + + # transform the data into koha-table style data + SetUTF8Flag($record); + my $olddata = TransformMarcToKoha( $record, $frameworkcode ); + my $biblio = Koha::Biblio->new( { frameworkcode => $frameworkcode, -- 2.39.5