From 38c5f9f7a7d5be2da38f317497d6bfc0c1d46c43 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 18 Jul 2022 11:49:57 +0000 Subject: [PATCH] Bug 7660: Use first available categorycode when none passed in The code that populates the patron messaging preferences on initial form load expects to have a category selected. Currently we only have one if one was passed to the form. When creating an account from a parent, we don't have a category explicitly selected - so we can just select the first of the possible categories To test: 1 - In KTD set 'Juvenile' category to have some messaging preferences 2 - Find a patron, say Edna Acosta, and 'Add guarantee' 3 - In new form preferences are blank, cancel 4 - Apply patch, restart all 5 - Go to Edna, click 'Add guarantee' 6 - Preferences are populated! 7 - Cancel 8 - Go to 'Patrons' module 9 - Click "+ New patron" 10 - Confirm messaging preferences load correctly when not adding child Signed-off-by: Sally --- members/memberentry.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/members/memberentry.pl b/members/memberentry.pl index d406817ecd..bddcb9824a 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -680,13 +680,14 @@ foreach my $category_type (qw(C A S P I X)) { my @categoryloop; while ( my $patron_category = $patron_categories->next ) { + $categorycode = $patron_category->categorycode unless defined($categorycode); #If none passed in, select the first push @categoryloop, { 'categorycode' => $patron_category->categorycode, 'categoryname' => $patron_category->description, 'effective_min_password_length' => $patron_category->effective_min_password_length, 'effective_require_strong_password' => $patron_category->effective_require_strong_password, 'categorycodeselected' => - ( defined($categorycode) && $patron_category->categorycode eq $categorycode ), + ( $patron_category->categorycode eq $categorycode ), }; } my %typehash; -- 2.30.2