Bug 35105: Fix patron accessor in Illrequest.pm
authorPedro Amorim <pedro.amorim@ptfs-europe.com>
Thu, 19 Oct 2023 10:42:48 +0000 (10:42 +0000)
committerMatt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Mon, 13 Nov 2023 14:28:49 +0000 (14:28 +0000)
commitdc24f439cad47b85704289ca1168a9c20ba97733
tree51a4db80ba686b93cd13bc4698db058f1c1d73da
parent25c328b8ea022101e2a41f9c8be51e7cfc3fd140
Bug 35105: Fix patron accessor in Illrequest.pm

Patron is nullable, so we need to consider undef return

Test plan, k-t-d:
1) Install FreeForm and enable ILLmodule, run:
bash <(curl -s https://raw.githubusercontent.com/ammopt/koha-ill-dev/master/start-ill-dev.sh)
2) Visit /cgi-bin/koha/ill/ill-requests.pl
3) Create 'New ILL request'
4) Select the request type, input cardnumber '42' and select a library
5) Hit 'Create'
6) Manage the request created just now: click the request id or 'manage request' button from the table
7) Click "Edit request" from the top actions toolbar
8a) Input text in Patron ID e.g. 'asdasdasf'. Notice you get redirected to the table - now renders correctly.
8b) Input a patron id that doesn't exist e.g. '987654'. Notice you get an error upon saving "FK Constraint error",
go back to the table and verify it renders correctly.

In both instances, the request is saved with borrowernumber as NULL,
this was preventing the table from rendering because the 'patron' API
embed was trying to retrieve a patron - getting an empty resultset instead
of undef.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 540626ef1510f9cae567efe646bb72f520cfbf2e)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 049285b441641d917c1d17bceff27a5f583db936)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Koha/Illrequest.pm