From 644cf730c83b7aa19d535b7615ee941f39c20f2e 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 Signed-off-by: Bob Bennhoff - CLiC --- Koha/Item.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 934e5f91b7..1f6da304c9 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -277,7 +277,8 @@ sub safe_to_delete { return "not_same_branch" if defined C4::Context->userenv - and !Koha::Patrons->find( C4::Context->userenv->{number} )->can_edit_item( $self ) ) + and defined C4::Context->userenv->{number} + and !Koha::Patrons->find( C4::Context->userenv->{number} )->can_edit_item( $self ); # check it doesn't have a waiting reserve return "book_reserved" -- 2.24.3 (Apple Git-128)