@@ -, +, @@ email addresses --- Koha/Patron.pm | 4 +++- t/db_dependent/Koha/Patrons.t | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) --- a/Koha/Patron.pm +++ a/Koha/Patron.pm @@ -1111,7 +1111,9 @@ sub anonymize { warn "Exiting anonymize: patron ".$self->borrowernumber." still has issues"; return; } - my $mandatory = { map { (lc $_, 1); } + # Mandatory fields come from the corresponding pref, but email fields + # are removed since scrambled email addresses only generate errors + my $mandatory = { map { (lc $_, 1); } grep { !/email/ } split /\s*\|\s*/, C4::Context->preference('BorrowerMandatoryField') }; $mandatory->{userid} = 1; # needed since sub store does not clear field my @columns = $self->_result->result_source->columns; --- a/t/db_dependent/Koha/Patrons.t +++ a/t/db_dependent/Koha/Patrons.t @@ -1581,7 +1581,7 @@ subtest 'lock' => sub { }; subtest 'anonymize' => sub { - plan tests => 9; + plan tests => 10; my $patron1 = $builder->build_object( { class => 'Koha::Patrons' } ); my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } ); @@ -1602,6 +1602,7 @@ subtest 'anonymize' => sub { isnt( $patron1->surname, $surname, 'Surname changed' ); ok( $patron1->surname =~ /^\w{10}$/, 'Mandatory surname randomized' ); is( $patron1->branchcode, $branchcode, 'Branch code skipped' ); + is( $patron1->email, undef, 'Email was mandatory, must be cleared' ); # Test wrapper in Koha::Patrons $patron1->surname($surname)->store; # restore --