From a4245efd875c74c9a342db0eb7cfbd72c8d6920d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 5 Jan 2018 16:36:31 -0300 Subject: [PATCH] Bug 19921: Fix update child when only one adult patron category exist We are passing the Koha::Patron::Category object to the template instead of the categorycode. To reproduce this bug you must test in a system which has only one patron category of the "adult" type. View the details of a patron with a child-type patron category and choose More -> Update child to adult patron. This results in an error: Can't call method "category_type" on an undefined value at /home/vagrant/kohaclone/members/update-child.pl line 84. The URL of the error page shows a problem with the parameters being passed: members/update-child.pl?op=update&borrowernumber=12345&catcode=Koha::Patron::Category=HASH(0xa168a18)&catcode_multi= Test plan: Make sure you have only 1 adult patron category Update a child to adult => With this patch applied the error is gone and the patron has been correctly updated Signed-off-by: Owen Leonard Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart Signed-off-by: Nick Clemens (cherry picked from commit d735b4957b6073c6d8bf085cc81382dc4dc50d06) Signed-off-by: Fridolin Somers --- circ/circulation.pl | 2 +- members/boraccount.pl | 2 +- members/mancredit.pl | 2 +- members/maninvoice.pl | 2 +- members/member-flags.pl | 2 +- members/member-password.pl | 2 +- members/moremember.pl | 2 +- members/pay.pl | 2 +- members/paycollect.pl | 2 +- members/printfeercpt.pl | 2 +- members/printinvoice.pl | 2 +- members/readingrec.pl | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index 5f85d793f3..9776449d98 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -551,7 +551,7 @@ my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber ); if ( $borrowernumber && $borrower->{'category_type'} eq 'C') { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; - $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1; + $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1; } my $messages = Koha::Patron::Messages->search( diff --git a/members/boraccount.pl b/members/boraccount.pl index 5991a56620..ae48338c14 100755 --- a/members/boraccount.pl +++ b/members/boraccount.pl @@ -63,7 +63,7 @@ if ( $action eq 'reverse' ) { if ( $data->{'category_type'} eq 'C') { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; - $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1; + $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1; } #get account details diff --git a/members/mancredit.pl b/members/mancredit.pl index 44a24fc0dd..a26000dc30 100755 --- a/members/mancredit.pl +++ b/members/mancredit.pl @@ -77,7 +77,7 @@ if ($add){ if ( $data->{'category_type'} eq 'C') { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; - $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1; + $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1; } $template->param( adultborrower => 1 ) if ( $data->{category_type} eq 'A' || $data->{category_type} eq 'I' ); diff --git a/members/maninvoice.pl b/members/maninvoice.pl index 0306f2a94a..3f49598e0e 100755 --- a/members/maninvoice.pl +++ b/members/maninvoice.pl @@ -103,7 +103,7 @@ if ($add){ if ( $data->{'category_type'} eq 'C') { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; - $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1; + $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1; } $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' ); diff --git a/members/member-flags.pl b/members/member-flags.pl index e8134ce67e..4b57316b00 100755 --- a/members/member-flags.pl +++ b/members/member-flags.pl @@ -173,7 +173,7 @@ if ($input->param('newflags')) { if ( $bor->{'category_type'} eq 'C') { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; - $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1; + $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1; } $template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' || $bor->{'category_type'} eq 'I' ); diff --git a/members/member-password.pl b/members/member-password.pl index 6413aff4e2..7902880533 100755 --- a/members/member-password.pl +++ b/members/member-password.pl @@ -102,7 +102,7 @@ else { if ( $bor->{'category_type'} eq 'C') { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; - $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1; + $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1; } $template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' || $bor->{'category_type'} eq 'I' ); diff --git a/members/moremember.pl b/members/moremember.pl index 34509bd656..8625d922fc 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -174,7 +174,7 @@ $data->{ "sex_".$data->{'sex'}."_p" } = 1 if defined $data->{sex}; if ( $category_type eq 'C') { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; - $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1; + $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1; } my @relatives; diff --git a/members/pay.pl b/members/pay.pl index 51bce06315..725556a44a 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -232,7 +232,7 @@ sub borrower_add_additional_fields { if ( $b_ref->{category_type} eq 'C' ) { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; - $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1; + $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1; } elsif ( $b_ref->{category_type} eq 'A' || $b_ref->{category_type} eq 'I' ) { $b_ref->{adultborrower} = 1; } diff --git a/members/paycollect.pl b/members/paycollect.pl index e7b63ecaba..969decb5f4 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -195,7 +195,7 @@ sub borrower_add_additional_fields { if ( $b_ref->{category_type} eq 'C' ) { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; - $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1; + $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1; } elsif ( $b_ref->{category_type} eq 'A' || $b_ref->{category_type} eq 'I' ) { $b_ref->{adultborrower} = 1; } diff --git a/members/printfeercpt.pl b/members/printfeercpt.pl index 4351aae1af..8b87f73013 100755 --- a/members/printfeercpt.pl +++ b/members/printfeercpt.pl @@ -60,7 +60,7 @@ if ( $action eq 'print' ) { if ( $data->{'category_type'} eq 'C') { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; - $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1; + $template->param( 'catcode' => $patron_categories->next->categorycde ) if $patron_categories->count == 1; } #get account details diff --git a/members/printinvoice.pl b/members/printinvoice.pl index 77f315630d..7a8a65f8e0 100755 --- a/members/printinvoice.pl +++ b/members/printinvoice.pl @@ -55,7 +55,7 @@ my $data = GetMember( 'borrowernumber' => $borrowernumber ); if ( $data->{'category_type'} eq 'C' ) { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; - $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1; + $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1; } #get account details diff --git a/members/readingrec.pl b/members/readingrec.pl index 9519b5040a..8596b5755e 100755 --- a/members/readingrec.pl +++ b/members/readingrec.pl @@ -98,7 +98,7 @@ if ( $op eq 'export_barcodes' ) { if ( $data->{'category_type'} eq 'C') { my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}); $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1; - $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1; + $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1; } $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' ); -- 2.39.5