From 585453fe20417779be84258b60d3d652d8e170e1 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 --- circ/circulation.pl | 2 +- members/boraccount.pl | 2 +- members/holdshistory.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 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index 98f4a78e77..5dc5d89a88 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -548,7 +548,7 @@ my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber ); if ( $patron && $patron->category->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 ac7cee248a..99884940f9 100755 --- a/members/boraccount.pl +++ b/members/boraccount.pl @@ -66,7 +66,7 @@ if ( $action eq 'reverse' ) { if ( $patron->category->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/holdshistory.pl b/members/holdshistory.pl index 9d6f7a48a8..06d0d1efde 100755 --- a/members/holdshistory.pl +++ b/members/holdshistory.pl @@ -77,7 +77,7 @@ if ( $borrowernumber eq C4::Context->preference('AnonymousPatron') ){ if ( $patron->category->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 ( $patron->category->category_type eq 'A' || $patron->category->category_type eq 'I' ); diff --git a/members/mancredit.pl b/members/mancredit.pl index 7534b8311d..fcfa1bf96d 100755 --- a/members/mancredit.pl +++ b/members/mancredit.pl @@ -80,7 +80,7 @@ if ($add){ if ( $patron->category->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 ( $patron->category->category_type =~ /^(A|I)$/ ); diff --git a/members/maninvoice.pl b/members/maninvoice.pl index 44d2b18447..6c646c14a4 100755 --- a/members/maninvoice.pl +++ b/members/maninvoice.pl @@ -107,7 +107,7 @@ if ($add){ if ( $patron->category->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 ( $patron->category->category_type =~ /^(A|I)$/ ); diff --git a/members/member-flags.pl b/members/member-flags.pl index 27e020c96a..ba01d3befc 100755 --- a/members/member-flags.pl +++ b/members/member-flags.pl @@ -181,7 +181,7 @@ if ($input->param('newflags')) { 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; } $template->param( adultborrower => 1 ) if ( $category_type =~ /^(A|I)$/ ); diff --git a/members/member-password.pl b/members/member-password.pl index db51b17226..efeadd7bb2 100755 --- a/members/member-password.pl +++ b/members/member-password.pl @@ -104,7 +104,7 @@ if ( $newpassword and not @errors) { 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; } $template->param( adultborrower => 1 ) if ( $category_type =~ /^(A|I)$/ ); diff --git a/members/moremember.pl b/members/moremember.pl index 27185efca5..f79f2f811e 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -172,7 +172,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 b1add01018..a248db0a51 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -235,7 +235,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 6bf0fee04e..6e2fe679a0 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -200,7 +200,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 f5933f16ab..8bce7a8892 100755 --- a/members/printfeercpt.pl +++ b/members/printfeercpt.pl @@ -67,7 +67,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 ff2c0d1ed6..53c9438266 100755 --- a/members/printinvoice.pl +++ b/members/printinvoice.pl @@ -62,7 +62,7 @@ $data->{category_type} = $category->category_type; 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 7fe990da9a..d94ff96b39 100755 --- a/members/readingrec.pl +++ b/members/readingrec.pl @@ -104,7 +104,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