From 63c93d3c114c6720100cd2b843e8989a1a0eecb7 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Tue, 22 Sep 2020 15:16:23 +0200 Subject: [PATCH] Bug 26506: Fix Koha::Account::pay if called when no user is logged-in Currently, Koha::Account::pay will fail if no user is logged-in when it is called. In this case, this patch will use undef instead of 0 for $manager_id in order to comply with the foreign key constraint on manager_id. Signed-off-by: Magnus Enger Biblibre and Libriotech have created a OPAC payment plugin that was having problems because of this bug. Applying the fix in this patch to a live server solved the problem. Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- Koha/Account.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/Account.pm b/Koha/Account.pm index 2a63856b52..5178d98639 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -95,7 +95,7 @@ sub pay { my $patron = Koha::Patrons->find( $self->{patron_id} ); - my $manager_id = $userenv ? $userenv->{number} : 0; + my $manager_id = $userenv ? $userenv->{number} : undef; my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface; Koha::Exceptions::Account::RegisterRequired->throw() if ( C4::Context->preference("UseCashRegisters") -- 2.39.5