View | Details | Raw Unified | Return to bug 14708
Collapse All | Expand All

(-)a/Koha/Patron.pm (-3 / +4 lines)
Lines 556-561 sub siblings { Link Here
556
sub merge_with {
556
sub merge_with {
557
    my ( $self, $patron_ids ) = @_;
557
    my ( $self, $patron_ids ) = @_;
558
558
559
    my $anonymous_patron = C4::Context->preference("AnonymousPatron");
560
    return if $anonymous_patron && $self->id eq $anonymous_patron;
561
559
    my @patron_ids = @{ $patron_ids };
562
    my @patron_ids = @{ $patron_ids };
560
563
561
    # Ensure the keeper isn't in the list of patrons to merge
564
    # Ensure the keeper isn't in the list of patrons to merge
Lines 568-576 sub merge_with { Link Here
568
    $self->_result->result_source->schema->txn_do( sub {
571
    $self->_result->result_source->schema->txn_do( sub {
569
        foreach my $patron_id (@patron_ids) {
572
        foreach my $patron_id (@patron_ids) {
570
573
571
            if ( my $anonymous_patron = C4::Context->preference("AnonymousPatron") ) {
574
            next if $patron_id eq $anonymous_patron;
572
                next if $patron_id eq $anonymous_patron;
573
            }
574
575
575
            my $patron = Koha::Patrons->find( $patron_id );
576
            my $patron = Koha::Patrons->find( $patron_id );
576
577
(-)a/t/db_dependent/Koha/Patrons.t (-2 / +6 lines)
Lines 1692-1698 subtest 'BorrowersLog tests' => sub { Link Here
1692
$schema->storage->txn_rollback;
1692
$schema->storage->txn_rollback;
1693
1693
1694
subtest 'Test Koha::Patrons::merge' => sub {
1694
subtest 'Test Koha::Patrons::merge' => sub {
1695
    plan tests => 111;
1695
    plan tests => 113;
1696
1696
1697
    my $schema = Koha::Database->new()->schema();
1697
    my $schema = Koha::Database->new()->schema();
1698
1698
Lines 1738-1743 subtest 'Test Koha::Patrons::merge' => sub { Link Here
1738
    is( Koha::Patrons->find($loser_2), undef, 'Loser 2 has been deleted' );
1738
    is( Koha::Patrons->find($loser_2), undef, 'Loser 2 has been deleted' );
1739
    is( ref Koha::Patrons->find($anonymous_patron), 'Koha::Patron', 'Anonymous Patron was not deleted' );
1739
    is( ref Koha::Patrons->find($anonymous_patron), 'Koha::Patron', 'Anonymous Patron was not deleted' );
1740
1740
1741
    $anonymous_patron = Koha::Patrons->find($anonymous_patron);
1742
    $results = $anonymous_patron->merge_with( [ $keeper->id ] );
1743
    is( $results, undef, "Anonymous patron cannot have other patrons merged into it" );
1744
    is( Koha::Patrons->search( { borrowernumber => $keeper->id } )->count, 1, "Patron from attempted merge with AnonymousPatron still exists" );
1745
1741
    t::lib::Mocks::mock_preference( 'AnonymousPatron', '' );
1746
    t::lib::Mocks::mock_preference( 'AnonymousPatron', '' );
1742
    $schema->storage->txn_rollback;
1747
    $schema->storage->txn_rollback;
1743
};
1748
};
1744
- 

Return to bug 14708