From 083a8f7b7274bdf9e9547bee60366259374c1c20 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 Signed-off-by: Kyle M Hall --- 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 5a1fe47f12..1bc76143e3 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 7330cb9cff..51012ed0a2 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.39.5