|
Lines 3364-3370
sub SendCirculationAlert {
Link Here
|
| 3364 |
# LOCK TABLES is not transaction-safe and implicitly commits any active transaction before attempting to lock the tables. |
3364 |
# LOCK TABLES is not transaction-safe and implicitly commits any active transaction before attempting to lock the tables. |
| 3365 |
# If the LOCK/UNLOCK statements are executed from tests, the current transaction will be committed. |
3365 |
# If the LOCK/UNLOCK statements are executed from tests, the current transaction will be committed. |
| 3366 |
# To avoid that we need to guess if this code is execute from tests or not (yes it is a bit hacky) |
3366 |
# To avoid that we need to guess if this code is execute from tests or not (yes it is a bit hacky) |
| 3367 |
my $called_from_tests = exists $ENV{_} and $ENV{_} =~ m|prove|; |
3367 |
my $do_not_lock = ( exists $ENV{_} && $ENV{_} =~ m|prove| ) || $ENV{KOHA_NO_TABLE_LOCKS}; |
| 3368 |
|
3368 |
|
| 3369 |
for my $mtt (@transports) { |
3369 |
for my $mtt (@transports) { |
| 3370 |
my $letter = C4::Letters::GetPreparedLetter ( |
3370 |
my $letter = C4::Letters::GetPreparedLetter ( |
|
Lines 3383-3399
sub SendCirculationAlert {
Link Here
|
| 3383 |
) or next; |
3383 |
) or next; |
| 3384 |
|
3384 |
|
| 3385 |
$schema->storage->txn_begin; |
3385 |
$schema->storage->txn_begin; |
| 3386 |
C4::Context->dbh->do(q|LOCK TABLE message_queue READ|) unless $called_from_tests; |
3386 |
C4::Context->dbh->do(q|LOCK TABLE message_queue READ|) unless $do_not_lock; |
| 3387 |
C4::Context->dbh->do(q|LOCK TABLE message_queue WRITE|) unless $called_from_tests; |
3387 |
C4::Context->dbh->do(q|LOCK TABLE message_queue WRITE|) unless $do_not_lock; |
| 3388 |
my $message = C4::Message->find_last_message($borrower, $type, $mtt); |
3388 |
my $message = C4::Message->find_last_message($borrower, $type, $mtt); |
| 3389 |
unless ( $message ) { |
3389 |
unless ( $message ) { |
| 3390 |
C4::Context->dbh->do(q|UNLOCK TABLES|) unless $called_from_tests; |
3390 |
C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock; |
| 3391 |
C4::Message->enqueue($letter, $borrower, $mtt); |
3391 |
C4::Message->enqueue($letter, $borrower, $mtt); |
| 3392 |
} else { |
3392 |
} else { |
| 3393 |
$message->append($letter); |
3393 |
$message->append($letter); |
| 3394 |
$message->update; |
3394 |
$message->update; |
| 3395 |
} |
3395 |
} |
| 3396 |
C4::Context->dbh->do(q|UNLOCK TABLES|) unless $called_from_tests; |
3396 |
C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock; |
| 3397 |
$schema->storage->txn_commit; |
3397 |
$schema->storage->txn_commit; |
| 3398 |
} |
3398 |
} |
| 3399 |
|
3399 |
|
| 3400 |
- |
|
|