From 5c2c564d781b092ed431d7e439b82c4ccec73d32 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 18 Jan 2017 17:12:30 +0100 Subject: [PATCH] Bug 17933 - Internal software error when searching patron without birth date When patrons don't have date of birth (which is not required) patron search results on moremember page produce internal server error since we can't convert MySQL invalid date 0000-00-00 to datetime object and call strfdate on it. Additionally, since we assign dates to template variables and after than assign whole $data hash to template, later assigment overrides previous one, so we see birth date field even for patrons which don't have one. This patch fixes both of those problems. Test: 1. edit patron and remove it's birth date 2. try to search for it, and verify server error 3. apply patch 4. repeat search for patron and verify that it works and doesn't have enpty birth date field Signed-off-by: Grace McKenzie Signed-off-by: Nick Clemens --- Koha/Patron.pm | 3 ++- members/moremember.pl | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 5a1fe47..1bc7614 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -545,7 +545,8 @@ Return the age of the patron sub get_age { my ($self) = @_; my $today_str = dt_from_string->strftime("%Y-%m-%d"); - my $dob_str = dt_from_string( $self->dateofbirth )->strftime("%Y-%m-%d"); + my $dob_str = dt_from_string( $self->dateofbirth ) || return; + $dob_str = $dob_str->strftime("%Y-%m-%d"); my ( $dob_y, $dob_m, $dob_d ) = split /-/, $dob_str; my ( $today_y, $today_m, $today_d ) = split /-/, $today_str; diff --git a/members/moremember.pl b/members/moremember.pl index 7330cb9..51012ed 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -146,7 +146,7 @@ foreach (qw(dateenrolled dateexpiry dateofbirth)) { $data->{$_} = ''; next; } - $template->param( $_ => dt_from_string( $userdate ) ); + $data->{$_} = dt_from_string( $userdate ); } $data->{'IS_ADULT'} = ( $data->{'categorycode'} ne 'I' ); -- 2.1.4