Bugzilla – Attachment 60357 Details for
Bug 17933
Internal software error when searching patron without birth date
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17933: Add test and return unless defined dob
Bug-17933-Add-test-and-return-unless-defined-dob.patch (text/plain), 2.00 KB, created by
Nick Clemens (kidclamp)
on 2017-02-16 16:40:29 UTC
(
hide
)
Description:
Bug 17933: Add test and return unless defined dob
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-02-16 16:40:29 UTC
Size:
2.00 KB
patch
obsolete
>From a70203c26424578718447ef42b119e6d4140d05a Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 19 Jan 2017 11:13:36 +0100 >Subject: [PATCH] Bug 17933: Add test and return unless defined dob > >Without this patch get_age return actually 0 instead of > >Signed-off-by: Dobrica Pavlinusic <dpavlin@rot13.org> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/Patron.pm | 4 ++-- > t/db_dependent/Koha/Patrons.t | 4 +++- > 2 files changed, 5 insertions(+), 3 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 1bc7614..b79b58a 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -545,8 +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 ) || return; >- $dob_str = $dob_str->strftime("%Y-%m-%d"); >+ return unless $self->dateofbirth; >+ my $dob_str = dt_from_string( $self->dateofbirth )->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/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 0e6791a..2fbe737 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -492,13 +492,15 @@ subtest 'checkouts + get_overdues' => sub { > }; > > subtest 'get_age' => sub { >- plan tests => 6; >+ plan tests => 7; > > my $patron = $builder->build( { source => 'Borrower' } ); > $patron = Koha::Patrons->find( $patron->{borrowernumber} ); > > my $today = dt_from_string; > >+ $patron->dateofbirth( undef ); >+ is( $patron->get_age, undef, 'get_age should return undef if no dateofbirth is defined' ); > $patron->dateofbirth( $today->clone->add( years => -12, months => -6, days => -1 ) ); > is( $patron->get_age, 12, 'Patron should be 12' ); > $patron->dateofbirth( $today->clone->add( years => -18, months => 0, days => 1 ) ); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17933
:
59172
|
59194
|
59214
|
59215
|
59733
|
59734
|
59735
|
59736
|
60356
| 60357 |
60358