From fb9e7390b0a63dfe2ccc120c35f50f9eb68835c1 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 --- Koha/Item.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 6469671eb0..1510b3d915 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -227,7 +227,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)