From d579be3ff989f52738238e300b7289be2289dee6 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 12 Mar 2021 06:07:44 -0500 Subject: [PATCH] Bug 20718: Set owner to NULL when owner is deleted --- Koha/Patron.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 8c1592c3f2..f17ffd3022 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -386,7 +386,11 @@ sub delete { # This pref should then govern the results of other routines/methods such as # Koha::Virtualshelf->new->delete too. # FIXME Could be $patron->get_lists - $_->delete for Koha::Virtualshelves->search( { owner => $self->borrowernumber } ); + # + # Set owner to NULL if the list is an "all staff" list, otherwise delete it. + $_->category == 3 ? $_->owner(undef)->store() : $_->delete + for Koha::Virtualshelves->search( + { owner => $self->borrowernumber } ); # We cannot have a FK on borrower_modifications.borrowernumber, the table is also used # for patron selfreg -- 2.24.1 (Apple Git-126)