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 <magnus@libriotech.no>
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 <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 63c93d3c11)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Matthias Meusburger 2020-09-22 15:16:23 +02:00 committed by Lucas Gass
parent 1ee8f1f1c2
commit 8a5898aab8
1 changed files with 1 additions and 1 deletions

View File

@ -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")