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

(-)a/Koha/Patrons.pm (-1 / +3 lines)
Lines 224-237 sub anonymise_issue_history { Link Here
224
224
225
sub delete {
225
sub delete {
226
    my ( $self, $params ) = @_;
226
    my ( $self, $params ) = @_;
227
    my $patrons_deleted;
227
    $self->_resultset->result_source->schema->txn_do( sub {
228
    $self->_resultset->result_source->schema->txn_do( sub {
228
        my ( $set, $params ) = @_;
229
        my ( $set, $params ) = @_;
229
        while( my $patron = $set->next ) {
230
        while( my $patron = $set->next ) {
230
            $patron->move_to_deleted if $params->{move};
231
            $patron->move_to_deleted if $params->{move};
231
            $patron->delete == 1 || Koha::Exceptions::Patron::Delete->throw;
232
            $patron->delete == 1 || Koha::Exceptions::Patron::Delete->throw;
233
            $patrons_deleted++;
232
        }
234
        }
233
    }, $self, $params );
235
    }, $self, $params );
234
    return 1;
236
    return $patrons_deleted;
235
}
237
}
236
238
237
=head3 _type
239
=head3 _type
(-)a/t/db_dependent/Koha/Patrons.t (-2 / +1 lines)
Lines 435-441 subtest 'Koha::Patrons->delete' => sub { Link Here
435
    my $id1 = $patron1->borrowernumber;
435
    my $id1 = $patron1->borrowernumber;
436
    my $set = Koha::Patrons->search({ borrowernumber => { '>=' => $id1 }});
436
    my $set = Koha::Patrons->search({ borrowernumber => { '>=' => $id1 }});
437
    is( $set->count, 2, 'Two patrons found as expected' );
437
    is( $set->count, 2, 'Two patrons found as expected' );
438
    is( $set->delete({ move => 1 }), 1, 'Two patrons deleted' );
438
    is( $set->delete({ move => 1 }), 2, 'Two patrons deleted' );
439
    is( $moved_to_deleted, 2, 'Patrons moved to deletedborrowers' );
439
    is( $moved_to_deleted, 2, 'Patrons moved to deletedborrowers' );
440
440
441
    # Add again, test if we can raise an exception
441
    # Add again, test if we can raise an exception
442
- 

Return to bug 21337