From 59fcad685e8143bfaeb7a148f248cc7b7f80b742 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 24 May 2017 12:24:53 -0300 Subject: [PATCH] Bug 18651: Use a READ and WRITE LOCK For more info, see: commit be156d9ad9e5bcfadab34d44f90e04fd61e256ad Bug 15854: Use a READ and WRITE LOCK on message_queue and commit b40456f7dd4b8a988f9c6a5718452936101cb8ff Bug 18364: Do not LOCK/UNLOCK tables from tests Signed-off-by: Chris Cormack Signed-off-by: Marcel de Rooy --- C4/Circulation.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 49827a86c9..60c29a9fce 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2172,7 +2172,12 @@ sub MarkIssueReturned { push @bind, $issue_id; # FIXME Improve the return value and handle it from callers + my $do_not_lock = ( exists $ENV{_} && $ENV{_} =~ m|prove| ) || $ENV{KOHA_NO_TABLE_LOCKS}; $schema->txn_do(sub { + + C4::Context->dbh->do(q|LOCK TABLE old_issues READ|) unless $do_not_lock; + C4::Context->dbh->do(q|LOCK TABLE old_issues WRITE|) unless $do_not_lock; + $dbh->do( $query, undef, @bind ); my $original_issue_id = $issue_id; @@ -2209,6 +2214,8 @@ sub MarkIssueReturned { my $patron = Koha::Patrons->find( $borrowernumber ); $item->last_returned_by( $patron ); } + + C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock; }); return $issue_id; -- 2.39.5