I think this is a rare case, but we need to guard against it.
Created attachment 190820 [details] [review] Bug 41510: Add test for effective_bookable with missing itemtype - Add test case for the scenario where an item has no itemtype because both items.itype and biblioitems.itemtype are NULL - Note: We must set biblioitems.itemtype to NULL before creating the item because Koha::Item->store() automatically populates itype from biblioitems.itemtype when itype is not set Test plan: - Apply this patch only - Run: prove t/db_dependent/Koha/Item.t :: effective_bookable - Verify test 6 FAILS with "Can't call method 'bookable' on an undefined value" - Apply the follow-up patch - Run the test again - Verify all tests PASS
Created attachment 190821 [details] [review] Bug 41510: Handle undefined itemtype in item->effective_bookable - Guard against undefined itemtype before calling ->bookable on it - Return 0 (not bookable) when no itemtype is found and item-level bookable is not defined
Created attachment 190854 [details] [review] Bug 41510: Add test for effective_bookable with missing itemtype - Add test case for the scenario where an item has no itemtype because both items.itype and biblioitems.itemtype are NULL - Note: We must set biblioitems.itemtype to NULL before creating the item because Koha::Item->store() automatically populates itype from biblioitems.itemtype when itype is not set Test plan: - Apply this patch only - Run: prove t/db_dependent/Koha/Item.t :: effective_bookable - Verify test 6 FAILS with "Can't call method 'bookable' on an undefined value" - Apply the follow-up patch - Run the test again - Verify all tests PASS Signed-off-by: David Nind <david@davidnind.com>
Created attachment 190855 [details] [review] Bug 41510: Handle undefined itemtype in item->effective_bookable - Guard against undefined itemtype before calling ->bookable on it - Return 0 (not bookable) when no itemtype is found and item-level bookable is not defined Signed-off-by: David Nind <david@davidnind.com>