From 4a71253326850ba876a78b67ef000b415feadbbb 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 --- Koha/ArticleRequest.pm | 1 - Koha/Patron.pm | 16 +++++++--------- admin/categories.pl | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Koha/ArticleRequest.pm b/Koha/ArticleRequest.pm index ac531e8ea4..6c47483d95 100644 --- a/Koha/ArticleRequest.pm +++ b/Koha/ArticleRequest.pm @@ -26,7 +26,6 @@ use Koha::Biblios; use Koha::Items; use Koha::Libraries; use Koha::DateUtils qw( dt_from_string ); -use Koha::ArticleRequests; use Koha::Exceptions::ArticleRequest; use base qw(Koha::Object); diff --git a/Koha/Patron.pm b/Koha/Patron.pm index bbdb8d8ff1..4a646cad5b 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 => ['PENDING','PROCESSING'] }, + { 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.25.1