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>
tags/v19.05.00
parent
commit
6388ffd702
2 changed files with 4 additions and 2 deletions
  1. +2
    -1
      Koha/Template/Plugin/Categories.pm
  2. +2
    -1
      opac/opac-password-recovery.pl

+ 2
- 1
Koha/Template/Plugin/Categories.pm View File

@@ -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;
}


+ 2
- 1
opac/opac-password-recovery.pl View File

@@ -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