From e891af74e6a2bc25b39150cfa9a02e0b14a2b81d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Fri, 23 Jun 2017 17:48:32 +0200 Subject: [PATCH] Bug 16711: (QA-followup) Use count directly See comment # 13 Signed-off-by: Nick Clemens --- opac/opac-password-recovery.pl | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/opac/opac-password-recovery.pl b/opac/opac-password-recovery.pl index 0a35e78..f15a93e 100755 --- a/opac/opac-password-recovery.pl +++ b/opac/opac-password-recovery.pl @@ -36,7 +36,6 @@ my $borrower_number; #errors my $hasError; -my $resultCount; #email form error my $errNoBorrowerFound; @@ -56,31 +55,29 @@ if ( $query->param('sendEmail') || $query->param('resendEmail') ) { #try with the main email $email ||= ''; # avoid undef my $borrower; - my $search_results = []; + my $search_results; # Find the borrower by his userid or email if ($username) { - $search_results = [ Koha::Patrons->search( { userid => $username } ) ]; - $resultCount = Koha::Patrons->search( { userid => $username } ) -> count + $search_results = Koha::Patrons->search( { userid => $username } ); } elsif ($email) { - $search_results = [ Koha::Patrons->search( { -or => { email => $email, emailpro => $email, B_email => $email } } ) ]; - $resultCount = Koha::Patrons->search( { -or => { email => $email, emailpro => $email, B_email => $email } } ) -> count; + $search_results = Koha::Patrons->search( { -or => { email => $email, emailpro => $email, B_email => $email } } ); } - if ( not $search_results || $resultCount < 1) { + if ( not $search_results || $search_results->count < 1) { $hasError = 1; $errNoBorrowerFound = 1; } - elsif ( $username && scalar $resultCount > 1) { # Multiple accounts for username + elsif ( $username && $search_results->count > 1) { # Multiple accounts for username $hasError = 1; $errNoBorrowerFound = 1; } - elsif ( $email && scalar $resultCount > 1) { # Muliple accounts for E-Mail + elsif ( $email && $search_results->count > 1) { # Muliple accounts for E-Mail $hasError = 1; $errMultipleAccountsForEmail = 1; } - elsif ( $borrower = shift @$search_results ) { # One matching borrower + elsif ( $borrower = $search_results->next() ) { # One matching borrower $username ||= $borrower->userid; my @emails = ( $borrower->email, $borrower->emailpro, $borrower->B_email ); -- 2.1.4