From 8da920a98ad2b4f32686dbd7f4846fe4c8360a65 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 a0aaa5f82b..9e1d51ea64 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -267,7 +267,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.1 (Apple Git-126)