https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43604 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 206586 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206586&action=edit Bug 43604: Fix Koha::Item->safe_to_delete crash when userenv has no matching patron Koha::Item->safe_to_delete assumed C4::Context->userenv->{number} always corresponds to a real Koha::Patron. misc/commit_file.pl sets a dummy CLI userenv with borrowernumber 0, so running --revert on a batch calls safe_delete/safe_to_delete on each item and dies: Can't call method "can_edit_items_from" on an undefined value at Koha/Item.pm line 374. Guard against Koha::Patrons->find returning undef, matching the pattern already used elsewhere (e.g. Koha::UI::Table::Builder::Items->build_table). Test plan: 1. Run misc/commit_file.pl --batch-number NNN --revert on a committed import batch -- it dies as above. 2. Apply this patch. 3. prove t/db_dependent/Koha/Item.t -- all tests pass. 4. Repeat step 1 -- the batch reverts successfully. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.