Bug 19484

Summary: Checkout page does not like itemtype NULL
Product: Koha Reporter: Marcel de Rooy <m.de.rooy>
Component: CirculationAssignee: Marcel de Rooy <m.de.rooy>
Status: CLOSED FIXED QA Contact: Kyle M Hall <kyle>
Severity: normal    
Priority: P5 - low CC: gmcharlt, jonathan.druart, kyle.m.hall, kyle
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 19484: Add test before using object itemtype
Bug 19484: Add test before using object itemtype
Bug 19484: Add test before using object itemtype

Description Marcel de Rooy 2017-10-18 13:59:55 UTC
Somehow an imported item had no itemtype (might be another bug btw), but anyway it results in a never ending loading of checkouts since svc/checkouts crashes.
Resolved by a simple test.

item-level_itypes set but no itemtype set for item (451) at /usr/share/koha/masterclone/Koha/Schema/Result/Item.pm line 698.
Can't call method "translated_description" on an undefined value at /usr/share/koha/masterclone/svc/checkouts line 168.
Comment 1 Marcel de Rooy 2017-10-18 14:04:43 UTC
Created attachment 68250 [details] [review]
Bug 19484: Add test before using object itemtype

Resolves this crash:
item-level_itypes set but no itemtype set for item (451) at /usr/share/koha/masterclone/Koha/Schema/Result/Item.pm line 698.
Can't call method "translated_description" on an undefined value at /usr/share/koha/masterclone/svc/checkouts line 168.

Test plan:
[1] Create/update an item so that it has itemtype NULL.
[2] Check it out on Circulation page.
    Before this patch the loading would never stop.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 2 Marcel de Rooy 2017-10-18 14:49:54 UTC
Since itype is not a foreign key, it would also work to put say BKS into itype when you only have BK in your item types. (Update via mysql.)
Comment 3 Marcel de Rooy 2017-10-18 15:00:13 UTC
Since importing unknown itemtypes is possible, I am wondering what the severity of this bug should be btw..
Comment 4 Dilan Johnpullé 2017-10-19 00:13:19 UTC
Created attachment 68285 [details] [review]
Bug 19484: Add test before using object itemtype

Patch applies and functions as described. I agree with you that importing NULL itemtypes is possible Marcel. A higher importance level makes sense.

Signed-off-by: Dilan Johnpullé <dilan@calyx.net.au>
Comment 5 Marcel de Rooy 2017-10-19 06:24:09 UTC
(In reply to Dilan Johnpullé from comment #4)
> Created attachment 68285 [details] [review] [review]
> Bug 19484: Add test before using object itemtype
> 
> Patch applies and functions as described. I agree with you that importing
> NULL itemtypes is possible Marcel. A higher importance level makes sense.
> 
> Signed-off-by: Dilan Johnpullé <dilan@calyx.net.au>

Thanks
Comment 6 Kyle M Hall 2017-10-27 13:30:40 UTC
Created attachment 68703 [details] [review]
Bug 19484: Add test before using object itemtype

Patch applies and functions as described. I agree with you that importing NULL itemtypes is possible Marcel. A higher importance level makes sense.

Signed-off-by: Dilan Johnpullé <dilan@calyx.net.au>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 7 Jonathan Druart 2017-10-27 15:28:40 UTC
There was a thread on the ML: http://lists.koha-community.org/pipermail/koha-devel/2017-July/043841.html
"Expected behaviour if itemtype does not exist"

The correct solution would be to provide a script to make sure the data are correct and/or display a warning message on the about page.
Comment 8 Jonathan Druart 2017-10-27 17:17:10 UTC
Pushed to master for 17.11, thanks to everybody involved!