[Koha-bugs] [Bug 26506] New: Koha::Account::pay will fail if $userenv is not set
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Tue Sep 22 15:14:31 CEST 2020
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26506
Bug ID: 26506
Summary: Koha::Account::pay will fail if $userenv is not set
Change sponsored?: ---
Product: Koha
Version: master
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P5 - low
Component: Fines and fees
Assignee: koha-bugs at lists.koha-community.org
Reporter: matthias.meusburger at biblibre.com
QA Contact: testopia at bugs.koha-community.org
Koha::Account::pay will fail if $userenv is not set.
The context would be a payment plugin for the opac, in which the payment system
will call a callback URL to confirm the payment has been made. In this
situation, no user is logged in when the plugin uses Koha::Account::pay.
The problem is that the following line in Koha::Account::pay:
my $manager_id = $userenv ? $userenv->{number} : 0;
will result in an SQL error, since $userenv->{number} is not set, and 0 is not
an acceptable value because of foreign key constraint:
DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key
constraint fails (`koha_hkr`.`accountlines`, CONSTRAINT
`accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES
`borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE)
By the way, if you have a look at C4/Accounts.pm, in the manualinvoice
function:
my $manager_id = C4::Context->userenv ? C4::Context->userenv->{'number'} :
undef;
$manager_id will be set to undef, which will not fail, since undef is an
acceptable value regarding to SQL foreign key constraints.
It's hard to provide a test plan, since it relies on a plugin, sorry, but I
will try to answer to any question :)
--
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.
More information about the Koha-bugs
mailing list