From b0a77687ac1ece0b767da836b7e9c7d37e10e698 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 3 Aug 2022 11:20:20 +0000 Subject: [PATCH] Bug 31288: (QA follow-up) Check userenv in disown_or_delete Test plan: 1. Apply the regression tests 2. Run: $ kshell k$ t/db_dependent/Koha/Virtualshelves.t => FAIL: Tests fail! 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- Koha/Virtualshelves.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/Virtualshelves.pm b/Koha/Virtualshelves.pm index d4605883a3..2b82dfc732 100644 --- a/Koha/Virtualshelves.pm +++ b/Koha/Virtualshelves.pm @@ -55,12 +55,12 @@ sub disown_or_delete { if C4::Context->preference('ListOwnerDesignated') and Koha::Patrons->find( C4::Context->preference('ListOwnerDesignated') ); - unless ($new_owner) { + if( !$new_owner && C4::Context->userenv ) { $new_owner = C4::Context->userenv->{number}; } while ( my $list = $self->next ) { - if ( $list->is_public or $list->is_shared ) { + if ( $new_owner && ( $list->is_public or $list->is_shared ) ) { $list->transfer_ownership($new_owner); } else { $list->delete; -- 2.39.5