Bug 20023: (QA follow-up) Tiny simplification

Remove empty emails from the list rightaway.
Would be tempted to lc the params->{email} at the start btw..

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Marcel de Rooy 2018-09-21 11:38:15 +02:00 committed by Nick Clemens
parent cc3bc29207
commit eec74a2cd1

View file

@ -73,13 +73,9 @@ if ( $query->param('sendEmail') || $query->param('resendEmail') ) {
$errMultipleAccountsForEmail = 1;
}
elsif ( $borrower = $search_results->next() ) { # One matching borrower
my @emails = ( $borrower->email || '', $borrower->emailpro || '', $borrower->B_email || '');
my @emails = grep { $_ } ( $borrower->email, $borrower->emailpro, $borrower->B_email );
my $firstNonEmptyEmail = '';
foreach my $address ( @emails ) {
$firstNonEmptyEmail = $address if length $address;
last if $firstNonEmptyEmail;
}
my $firstNonEmptyEmail = shift @emails;
# Is the given email one of the borrower's ?
if ( $email && !( grep /^$email$/i, @emails ) ) {