Bugzilla – Attachment 135525 Details for
Bug 30874
Simplify patron category handling in memberentry
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30874: Reduce number of category fetches
Bug-30874-Reduce-number-of-category-fetches.patch (text/plain), 3.13 KB, created by
Jonathan Druart
on 2022-06-01 08:10:54 UTC
(
hide
)
Description:
Bug 30874: Reduce number of category fetches
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-06-01 08:10:54 UTC
Size:
3.13 KB
patch
obsolete
>From 27fca4719f5c61f5b385c94c978d9667ff6688ec Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 1 Jun 2022 09:59:31 +0200 >Subject: [PATCH] Bug 30874: Reduce number of category fetches > >--- > members/memberentry.pl | 19 +++++++++---------- > 1 file changed, 9 insertions(+), 10 deletions(-) > >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 3b93a801a30..03a376b3801 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -177,14 +177,14 @@ if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) { > > my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'}; > my $category_type = $input->param('category_type') || ''; >-my $category; >-if ( !$category_type && $categorycode ) { >- $category = Koha::Patron::Categories->find($categorycode); >- $category_type = $category->category_type; >- $template->param( patron_category => $category ); >-} >+ >+my $category = Koha::Patron::Categories->find($categorycode); >+$category_type ||= $category && $category->category_type; >+ > $category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error ! > >+$template->param( patron_category => $category ); >+ > # if a add or modify is requested => check validity of data. > %data = %$borrower_data if ($borrower_data); > >@@ -354,8 +354,7 @@ if ($op eq 'save' || $op eq 'insert'){ > if ( $dateofbirth ) { > my $patron = Koha::Patron->new({ dateofbirth => $dateofbirth }); > my $age = $patron->get_age; >- my $borrowercategory = Koha::Patron::Categories->find($categorycode); >- my ($low,$high) = ($borrowercategory->dateofbirthrequired, $borrowercategory->upperagelimit); >+ my ($low,$high) = ($category->dateofbirthrequired, $category->upperagelimit); > if (($high && ($age > $high)) or ($age < $low)) { > push @errors, 'ERROR_age_limitations'; > $template->param( age_low => $low); >@@ -385,7 +384,7 @@ if ($op eq 'save' || $op eq 'insert'){ > push @errors, "ERROR_password_mismatch" if ( $password ne $password2 ); > > if ( $password and $password ne '****' ) { >- my ( $is_valid, $error ) = Koha::AuthUtils::is_password_valid( $password, Koha::Patron::Categories->find($categorycode) ); >+ my ( $is_valid, $error ) = Koha::AuthUtils::is_password_valid( $password, $category ); > unless ( $is_valid ) { > push @errors, 'ERROR_password_too_short' if $error eq 'too_short'; > push @errors, 'ERROR_password_too_weak' if $error eq 'too_weak'; >@@ -822,7 +821,7 @@ if (C4::Context->preference('EnhancedMessagingPreferences')) { > } > > $template->param( borrower_data => \%data ); >-$template->param( "show_guarantor" => $categorycode ? Koha::Patron::Categories->find($categorycode)->canbeguarantee : 1); # associate with step to know where you are >+$template->param( "show_guarantor" => $category ? $category->canbeguarantee : 1); # associate with step to know where you are > $template->param( "step_$step" => 1) if $step; # associate with step to know where u are > $template->param( step => $step ) if $step; # associate with step to know where u are > >-- >2.25.1
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 30874
:
135524
|
135525
|
135526
|
135527
|
135528
|
135529
|
138443
|
138444
|
138445
|
138446
|
138447
|
138545
|
138546
|
138547
|
138548
|
138549
|
138637
|
138638
|
138639
|
138640
|
138641