From 283fd1d3bdfe3db2f1e654f39e513c7019e5ba90 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Fri, 20 Aug 2021 09:45:48 +0000 Subject: [PATCH] Bug 27945: (follow-up) fix limit check in Patron.pm, regexp in categories.pl and removed unwanted use Koha::ArticleRequests in ArticleRequest.pm Signed-off-by: Marcel de Rooy --- Koha/Patron.pm | 16 +++++++--------- admin/categories.pl | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 10033139b8..e7c0940e74 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -972,18 +972,16 @@ sub can_request_article { return 1 if !$limit; - my $date = dt_from_string; - my $count = Koha::ArticleRequests->search({ - borrowernumber => $self->borrowernumber, - status => {'!=' => 'CANCELED'}, - created_on => { - '>=' => $date->date.' 00:00:00', - '<=' => $date->date.' 23:59:59' - } - })->count; + my $dtf = Koha::Database->new->schema->storage->datetime_parser; + my $compdate = dt_from_string->add( days => -1 ); + my $count = Koha::ArticleRequests->search([ + { borrowernumber => $self->borrowernumber, status => { '!=' => ['CANCELED','COMPLETED'] } }, + { borrowernumber => $self->borrowernumber, status => 'COMPLETED', updated_on => { '>', $dtf->format_date($compdate) }}, + ])->count; return $count < $limit ? 1 : 0; } + =head3 article_requests my @requests = $borrower->article_requests(); diff --git a/admin/categories.pl b/admin/categories.pl index 958bfd7c76..bd11fa96e9 100644 --- a/admin/categories.pl +++ b/admin/categories.pl @@ -77,7 +77,7 @@ if ( $op eq 'add_validate' ) { my $is_a_modif = $input->param("is_a_modif"); - if ($article_request_limit ne '' && $article_request_limit !~ /\d+/) { + if ($article_request_limit ne '' && $article_request_limit !~ /^\d+$/) { push @messages, {type => 'error', code => 'article_request_numeric_limit' }; $op = 'add_form'; } elsif ($article_request_limit ne '' && $article_request_limit < 0) { -- 2.30.2