Bugzilla – Attachment 103028 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 Anonymous Patron into other patron records
Bug-14708-Dont-allow-merging-of-Anonymous-Patron-i.patch (text/plain), 2.44 KB, created by
Kyle M Hall
on 2020-04-15 17:48:22 UTC
(
hide
)
Description:
Bug 14708: Don't allow merging of Anonymous Patron into other patron records
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2020-04-15 17:48:22 UTC
Size:
2.44 KB
patch
obsolete
>From b580a64c1ef94aabe450cc8a22f54210a4ea761c Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 15 Apr 2020 13:48:09 -0400 >Subject: [PATCH] Bug 14708: Don't allow merging of Anonymous Patron into other > patron records > >--- > Koha/Patron.pm | 5 +++++ > t/db_dependent/Koha/Patrons.t | 8 +++++++- > 2 files changed, 12 insertions(+), 1 deletion(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 17ef09cb90..b4aea038b8 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -549,6 +549,11 @@ 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; >+ } >+ > my $patron = Koha::Patrons->find( $patron_id ); > > next unless $patron; >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 30a28c1576..3a7701c2d9 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -1680,7 +1680,7 @@ subtest 'BorrowersLog tests' => sub { > $schema->storage->txn_rollback; > > subtest 'Test Koha::Patrons::merge' => sub { >- plan tests => 110; >+ plan tests => 111; > > my $schema = Koha::Database->new()->schema(); > >@@ -1692,6 +1692,10 @@ subtest 'Test Koha::Patrons::merge' => sub { > my $loser_1 = $builder->build({ source => 'Borrower' })->{borrowernumber}; > my $loser_2 = $builder->build({ source => 'Borrower' })->{borrowernumber}; > >+ my $anonymous_patron_orig = C4::Context->preference('AnonymousPatron'); >+ my $anonymous_patron = $builder->build({ source => 'Borrower' })->{borrowernumber}; >+ t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous_patron ); >+ > while (my ($r, $field) = each(%$resultsets)) { > $builder->build({ source => $r, value => { $field => $keeper->id } }); > $builder->build({ source => $r, value => { $field => $loser_1 } }); >@@ -1720,7 +1724,9 @@ subtest 'Test Koha::Patrons::merge' => sub { > > is( Koha::Patrons->find($loser_1), undef, 'Loser 1 has been deleted' ); > 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' ); > >+ t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); > $schema->storage->txn_rollback; > }; > >-- >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