Bugzilla – Attachment 103026 Details for
Bug 14708
The patron set as the anonymous patron should not be deletable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14708: Prevent deletion of Anonymous Patron at Koha::Patron::delete
Bug-14708-Prevent-deletion-of-Anonymous-Patron-at-.patch (text/plain), 1.98 KB, created by
Kyle M Hall (khall)
on 2020-04-15 17:21:04 UTC
(
hide
)
Description:
Bug 14708: Prevent deletion of Anonymous Patron at Koha::Patron::delete
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-04-15 17:21:04 UTC
Size:
1.98 KB
patch
obsolete
>From 4ee4e967af54e745c8bcf4ade433084b6af43d95 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 15 Apr 2020 12:48:02 -0400 >Subject: [PATCH] Bug 14708: Prevent deletion of Anonymous Patron at > Koha::Patron::delete > >--- > Koha/Patron.pm | 3 +++ > t/db_dependent/Koha/Patrons.t | 11 ++++++++++- > 2 files changed, 13 insertions(+), 1 deletion(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 9948f8c35c..17ef09cb90 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -359,6 +359,9 @@ other lists are kept. > sub delete { > my ($self) = @_; > >+ my $anonymous_patron = C4::Context->preference("AnonymousPatron"); >+ return $self if $anonymous_patron && $self->id eq $anonymous_patron; >+ > $self->_result->result_source->schema->txn_do( > sub { > # Cancel Patron's holds >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index d4582fcbd9..30a28c1576 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -1051,7 +1051,7 @@ subtest 'notice_email_address' => sub { > }; > > subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { >- plan tests => 4; >+ plan tests => 5; > > # TODO create a subroutine in t::lib::Mocks > my $branch = $builder->build({ source => 'Branch' }); >@@ -1065,6 +1065,15 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > > t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->{borrowernumber} ); > >+ subtest 'Anonymous Patron should be undeleteable' => sub { >+ plan tests => 1; >+ >+ my $anonymous_patron = Koha::Patrons->find( $anonymous->{borrowernumber} ); >+ $anonymous_patron->delete(); >+ $anonymous_patron = Koha::Patrons->find( $anonymous->{borrowernumber} ); >+ is( $anonymous_patron->id, $anonymous->{borrowernumber}, "Anonymous Patron was not deleted" ); >+ }; >+ > subtest 'patron privacy is 1 (default)' => sub { > plan tests => 9; > >-- >2.24.1 (Apple Git-126)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14708
:
85766
|
85770
|
85783
|
85789
|
103026
|
103027
|
103028
|
103922
|
105024
|
105025
|
105026
|
105027
|
105028
|
105029
|
105184
|
105185
|
105186
|
105187
|
105188
|
105189
|
112830
|
112831
|
112922
|
113121