Bug 14708: Don't allow merging of Anonymous Patron into other patron records
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit d9a54e0d33)
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
This commit is contained in:
parent
d5f92c4592
commit
2efc873e28
|
|
@ -568,6 +568,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;
|
||||
|
|
|
|||
|
|
@ -1692,7 +1692,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();
|
||||
|
||||
|
|
@ -1704,6 +1704,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 } });
|
||||
|
|
@ -1732,7 +1736,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;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue