From eb3db50d250c8488d4c95c6563b209ae01ae2aaa Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Thu, 25 Apr 2019 06:54:25 +0000 Subject: [PATCH] Bug 20256: (QA follow-up) test borrowernumber in userenv too Bug 22600 added userenv for scripts, so userenv is defined, but some of values in userenv not Test plan: Run with some params: misc/cronjobs/delete_items.pl --> without this patch you will se error message: Can't call method "can_edit_item" on an undefined value at /home/vagrant/kohaclone/C4/Items.pm line 1748 --> with this patch everything works smoothly --- C4/Items.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/Items.pm b/C4/Items.pm index 872db91aef..5efc6988df 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1730,7 +1730,7 @@ sub ItemSafeToDelete { if ($item->checkout) { $status = "book_on_loan"; } - elsif ( defined C4::Context->userenv + elsif ( defined C4::Context->userenv and defined C4::Context->userenv->{number} and !Koha::Patrons->find( C4::Context->userenv->{number} )->can_edit_item( $item ) ) { $status = "not_same_branch"; -- 2.21.0 (Apple Git-122.2)