From c414e7608956ca04648aed1a15b79c5cd281fb3c Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Wed, 2 Nov 2016 15:05:28 +0200 Subject: [PATCH] Bug 17539: Fix Already in a transaction error perl t/db_dependent/Reserves.t 1..72 ok 1 - use C4::Reserves; ok 2 - CheckReserves Test 1 ... ok 52 - Reserve in waiting status cant be canceled ok 53 - Reserving an ageRestricted Biblio without a borrower dateofbirth succeeds DBD::mysql::db begin_work failed: Already in a transaction at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1489. DBD::mysql::db begin_work failed: Already in a transaction at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1489. at /usr/share/perl5/DBIx/Class/Schema.pm line 1080. ... Koha::Object::store('Koha::Patron=HASH(0x9e43b20)') called at /home/ubuntu/kohaclone/C4/Members.pm line 542 C4::Members::ModMember('borrowernumber', 658535, 'dateofbirth', '2001-11-02') called at t/db_dependent/Reserves.t line 516 This patch fixes this issue by replacing dbh autocommit=0 with txn_begin. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- t/db_dependent/Reserves.t | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 1e9a067918..442c180bf9 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -50,8 +50,9 @@ $module->mock('userenv', sub { my $dbh = C4::Context->dbh; # Start transaction -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; +my $database = Koha::Database->new(); +my $schema = $database->schema(); +$schema->storage->txn_begin(); # Somewhat arbitrary field chosen for age restriction unit tests. Must be added to db before the framework is cached $dbh->do("update marc_subfield_structure set kohafield='biblioitems.agerestriction' where tagfield='521' and tagsubfield='a'"); @@ -678,7 +679,7 @@ is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); $dbh->do('DELETE FROM reserves', undef, ($bibnum)); # we reached the finish -$dbh->rollback; +$schema->storage->txn_rollback(); sub count_hold_print_messages { my $message_count = $dbh->selectall_arrayref(q{ -- 2.39.5