From 816eb139e84e42de9cd4303e9dfd997e85a6307e 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 Signed-off-by: Martin Renvoize --- Koha/Item.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 911faba573..37d6c9854b 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -298,7 +298,8 @@ sub safe_to_delete { $error = "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 $error = "book_reserved" -- 2.30.2