https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44335 Bug ID: 44335 Summary: Item home_library and holding_library die when the item has no library Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: adolfo.rodriguez@xercode.es QA Contact: testopia@bugs.koha-community.org Target Milestone: --- items.homebranch and items.holdingbranch can be NULL, and the API definition of an item declares home_library and holding_library as "object or null". However Koha::Item->home_library and holding_library always build a Koha::Library, and Koha::Object->_new_from_dbic croaks when there is no related row: DBIC result _type isn't of the _type Branch The items table of the record detail page requests both embeds, so a single item without a home or holding library makes GET /api/v1/biblios/{biblio_id}/items return a 500. The page cannot show any item of the record, including the one that would have to be edited to fix the data. Such items can be created, for example, from the acquisitions item form (see bug 44328), or come from migrated data. C4::ILSDI::Services already expects these methods to return undef. To reproduce: 1. UPDATE items SET homebranch = NULL, holdingbranch = NULL WHERE itemnumber = X; 2. Open the detail page of its record in the staff interface. => The items table cannot be loaded and the API log shows the error above. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.