Bugzilla – Attachment 105029 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: Don't allow merging of other patron records into Anonymous Patron
Bug-14708-Dont-allow-merging-of-other-patron-recor.patch (text/plain), 2.45 KB, created by
Andrew Fuerste-Henry
on 2020-05-18 14:39:25 UTC
(
hide
)
Description:
Bug 14708: Don't allow merging of other patron records into Anonymous Patron
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2020-05-18 14:39:25 UTC
Size:
2.45 KB
patch
obsolete
>From 0ef38c2711fb0aa3003823f0442f292d99291f0f Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 29 Apr 2020 07:22:26 -0400 >Subject: [PATCH] Bug 14708: Don't allow merging of other patron records into > Anonymous Patron > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > Koha/Patron.pm | 7 ++++--- > t/db_dependent/Koha/Patrons.t | 7 ++++++- > 2 files changed, 10 insertions(+), 4 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 9d47c95ad4..2dea6bbfae 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -556,6 +556,9 @@ sub siblings { > sub merge_with { > my ( $self, $patron_ids ) = @_; > >+ my $anonymous_patron = C4::Context->preference("AnonymousPatron"); >+ return if $anonymous_patron && $self->id eq $anonymous_patron; >+ > my @patron_ids = @{ $patron_ids }; > > # Ensure the keeper isn't in the list of patrons to merge >@@ -568,9 +571,7 @@ sub merge_with { > $self->_result->result_source->schema->txn_do( sub { > foreach my $patron_id (@patron_ids) { > >- if ( my $anonymous_patron = C4::Context->preference("AnonymousPatron") ) { >- next if $patron_id eq $anonymous_patron; >- } >+ next if $patron_id eq $anonymous_patron; > > my $patron = Koha::Patrons->find( $patron_id ); > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 6feeb150a3..81914cfeb0 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -1692,7 +1692,7 @@ subtest 'BorrowersLog tests' => sub { > $schema->storage->txn_rollback; > > subtest 'Test Koha::Patrons::merge' => sub { >- plan tests => 111; >+ plan tests => 113; > > my $schema = Koha::Database->new()->schema(); > >@@ -1738,6 +1738,11 @@ subtest 'Test Koha::Patrons::merge' => sub { > is( Koha::Patrons->find($loser_2), undef, 'Loser 2 has been deleted' ); > is( ref Koha::Patrons->find($anonymous_patron), 'Koha::Patron', 'Anonymous Patron was not deleted' ); > >+ $anonymous_patron = Koha::Patrons->find($anonymous_patron); >+ $results = $anonymous_patron->merge_with( [ $keeper->id ] ); >+ is( $results, undef, "Anonymous patron cannot have other patrons merged into it" ); >+ is( Koha::Patrons->search( { borrowernumber => $keeper->id } )->count, 1, "Patron from attempted merge with AnonymousPatron still exists" ); >+ > t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); > $schema->storage->txn_rollback; > }; >-- >2.11.0
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