Koha/members/member.pl
Jonathan Druart 9b34b07d62 Bug 17375: Search by dateofbirth - handle invalid dates
Prevent internal software error when searching patron with invalid birth date

To reproduce:

- Go to Home > Patron
- Expand patron search (click on + at the left of the search button)
- In drop down 'Search fields', select 'Date of birth'
- Enter a valid date (e.g. 11.02.1995 if syspref 'dateformat' is set to dmydot)
Result: Search works OK
- Enter an invalid date, e.g. 11.02 or abcd...
Result: Internal server error

- Do a patron search with many results
- Use filter on results screen, select 'Date of birth' as search field and
  enter an invalid date to search (e.g. 'a')
Result: Endless message 'Processing'

To test:
- Apply patch
- Repeat steps above
- In both cases, you should get "No results"

Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Lucio Moraes <lmoraes@catalyst.net.nz>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-10-27 13:18:32 +00:00

82 lines
2.7 KiB
Perl
Executable file

#!/usr/bin/perl
#script to do a borrower enquiry/bring up borrower details etc
#written 20/12/99 by chris@katipo.co.nz
# Copyright 2000-2002 Katipo Communications
# Copyright 2013 BibLibre
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use C4::Auth;
use C4::Output;
use CGI qw( -utf8 );
use C4::Members qw( GetMember );
use Koha::DateUtils;
use Koha::List::Patron;
my $input = new CGI;
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "members/member.tt",
query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => {borrowers => 1},
});
my $theme = $input->param('theme') || "default";
my $searchmember = $input->param('searchmember');
my $quicksearch = $input->param('quicksearch') // 0;
if ( $quicksearch and $searchmember ) {
my $branchcode;
if ( C4::Context::only_my_library ) {
my $userenv = C4::Context->userenv;
$branchcode = $userenv->{'branch'};
}
my $member = GetMember(
cardnumber => $searchmember,
( $branchcode ? ( branchcode => $branchcode ) : () ),
);
if( $member ){
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $member->{borrowernumber});
exit;
}
}
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
my $view = $input->request_method() eq "GET" ? "show_form" : "show_results";
$template->param(
patron_lists => [ GetPatronLists() ],
searchmember => $searchmember,
branchcode_filter => scalar $input->param('branchcode_filter'),
categorycode_filter => scalar $input->param('categorycode_filter'),
searchtype => scalar $input->param('searchtype') || 'contain',
searchfieldstype => $searchfieldstype,
PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
view => $view,
);
output_html_with_http_headers $input, $cookie, $template->output;