https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44335 --- Comment #1 from Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> --- Created attachment 212797 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212797&action=edit Bug 44335: Item home_library and holding_library die when the item has no library 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 one item without a library makes GET /api/v1/biblios/{biblio_id}/items return a 500 and the page cannot show any item of the record, including the one that would have to be edited to fix it. Such items can be created, for example, from the acquisitions item form (see bug 44328). C4::ILSDI::Services already expects these methods to return undef. Return undef when the item has no library, as the other accessors of Koha::Item (checkout, return_claim...) do. Steps to follow: 1. Create an item and set its libraries to NULL in the database: 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 (500 error) and the API log shows "DBIC result _type isn't of the _type Branch". 3. Apply the patch and restart the services (restart_all). 4. Reload the page. => The items table is shown and the library columns of the item are empty. 5. Edit the item, set its libraries and save. => The item is shown with its libraries. 6. Run: prove t/db_dependent/Koha/Item.t => All tests pass. -- You are receiving this mail because: You are watching all bug changes.