Browse Source

Bug 21890: (QA follow-up) Use List::Util::any

When possible it's a good idea to use `any` from List::Util to shortcut
on the first occurence of a truthy value.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
19.05.x
Martin Renvoize 5 years ago
committed by Nick Clemens
parent
commit
6388ffd702
  1. 3
      Koha/Template/Plugin/Categories.pm
  2. 3
      opac/opac-password-recovery.pl

3
Koha/Template/Plugin/Categories.pm

@ -20,6 +20,7 @@ use Modern::Perl;
use Template::Plugin;
use base qw( Template::Plugin );
use List::Util qw(any);
use Koha::Patron::Categories;
sub all {
@ -34,7 +35,7 @@ sub GetName {
}
sub can_any_reset_password {
return ( grep { $_->effective_reset_password } @{ Koha::Patron::Categories->search->as_list } )
return ( any { $_->effective_reset_password } @{ Koha::Patron::Categories->search->as_list } )
? 1
: 0;
}

3
opac/opac-password-recovery.pl

@ -14,6 +14,7 @@ use Koha::Patrons;
my $query = new CGI;
use HTML::Entities;
use Try::Tiny;
use List::Util qw/any/;
my ( $template, $dummy, $cookie ) = get_template_and_user(
{
@ -84,7 +85,7 @@ if ( $query->param('sendEmail') || $query->param('resendEmail') ) {
$firstNonEmptyEmail = $emails[0] if @emails;
# Is the given email one of the borrower's ?
if ( $email && !( grep /^$email$/i, @emails ) ) {
if ( $email && !( any { /^$email$/i } @emails ) ) {
$hasError = 1;
$errNoBorrowerFound = 1;
}

Loading…
Cancel
Save