https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43604

--- Comment #2 from David Nind <[email protected]> ---
Created attachment 207690
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207690&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 <[email protected]>
Signed-off-by: David Nind <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to