From b0ce0d646323de43739c454d0b8e665370768df1 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 27 Feb 2019 12:00:03 -0500 Subject: [PATCH] Bug 14708: Enforce restriction in delete_patrons.pl Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- misc/cronjobs/delete_patrons.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/misc/cronjobs/delete_patrons.pl b/misc/cronjobs/delete_patrons.pl index 3d25cb743a..f9ad0eca88 100755 --- a/misc/cronjobs/delete_patrons.pl +++ b/misc/cronjobs/delete_patrons.pl @@ -94,6 +94,7 @@ unless ($confirm) { say scalar(@$members) . " patrons to delete" if $verbose;; +my $anonymous_patron = C4::Context->preference("AnonymousPatron"); my $deleted = 0; for my $member (@$members) { print "Trying to delete patron $member->{borrowernumber}... " @@ -110,6 +111,13 @@ for my $member (@$members) { next; } + if ( $anonymous_patron ) { + if ( $patron->id eq $anonymous_patron ) { + say "Failed to delete patron $borrowernumber: patron is AnonymousPatron"; + next; + } + } + if ( $confirm ) { my $deleted = eval { $patron->move_to_deleted; }; if ($@ or not $deleted) { -- 2.39.5