From a6d3e31860bc7ae26c393ff2fe3b0bdde848ddee Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 18 Sep 2014 12:56:50 +0200 Subject: [PATCH] Bug 12957: Get rid of warnings in aqbudgets.pl There are a lot of warnings on navigating into the fund views (list, editing, etc.) "Use of uninitialized value in string eq..." "Use of uninitialized value in hash element" "Use of uninitialized value in concatenation..." Test plan: Verify the warnings don't appear anymore in logs on going on the fund list view, editing a fund, saving a fund. QA note: the budget_owner_name, budget_borrowernumber and branchname are never used on the fund list view. A call to GetMember has been removed. Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer This seems to work nicely reducing the amount of noise in the log considerably. Signed-off-by: Tomas Cohen Arazi --- admin/aqbudgets.pl | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/admin/aqbudgets.pl b/admin/aqbudgets.pl index 1a66c9c0f4..accdb78012 100755 --- a/admin/aqbudgets.pl +++ b/admin/aqbudgets.pl @@ -100,8 +100,7 @@ $template->param( op => $op, ); -# retrieve branches -my ( $budget, ); +my $budget; my $branches = GetBranches($show_mine); my @branchloop2; @@ -132,7 +131,7 @@ if ($op eq 'add_form') { } $dropbox_disabled = BudgetHasChildren($budget_id); my $borrower = &GetMember( borrowernumber=>$budget->{budget_owner_id} ); - $budget->{budget_owner_name} = $borrower->{'firstname'} . ' ' . $borrower->{'surname'}; + $budget->{budget_owner_name} = ( $borrower ? $borrower->{'firstname'} . ' ' . $borrower->{'surname'} : '' ); $$budget{$_}= sprintf("%.2f", $budget->{$_}) for grep{ /amount|encumb|expend/ } keys %$budget; } @@ -164,7 +163,7 @@ if ($op eq 'add_form') { value => $thisbranch, branchname => $branches->{$thisbranch}->{'branchname'}, ); - $row{selected} = 1 if $thisbranch eq $budget->{'budget_branchcode'}; + $row{selected} = 1 if $budget and $thisbranch eq $budget->{'budget_branchcode'}; push @branchloop_select, \%row; } @@ -173,14 +172,14 @@ if ($op eq 'add_form') { my @auth_cats_loop1 = (); foreach my $category (@$categories) { my $entry = { category => $category, - selected => $budget->{sort1_authcat} eq $category ?1:0, + selected => ( $budget and $budget->{sort1_authcat} eq $category ? 1 : 0 ), }; push @auth_cats_loop1, $entry; } my @auth_cats_loop2 = (); foreach my $category (@$categories) { my $entry = { category => $category, - selected => $budget->{sort2_authcat} eq $category ?1:0, + selected => ( $budget and $budget->{sort2_authcat} eq $category ? 1 : 0 ), }; push @auth_cats_loop2, $entry; } @@ -321,10 +320,6 @@ if ( $op eq 'list' ) { $budget->{"budget_spent"} = $num->format_price(0) unless defined($budget->{"budget_spent"}); $budget->{budget_ordered} = $num->format_price(0) unless defined($budget->{"budget_ordered"}); - my $borrower = &GetMember( borrowernumber=>$budget->{budget_owner_id} ); - $budget->{"budget_owner_name"} = $borrower->{'firstname'} . ' ' . $borrower->{'surname'}; - $budget->{"budget_borrowernumber"} = $borrower->{'borrowernumber'}; - #Make a list of parents of the bugdet my @budget_hierarchy; push @budget_hierarchy, { element_name => $budget->{"budget_name"}, element_id => $budget->{"budget_id"} }; @@ -337,7 +332,6 @@ if ( $op eq 'list' ) { push @budget_hierarchy, { element_name => $period->{"budget_period_description"} }; @budget_hierarchy = reverse(@budget_hierarchy); - $budget->{branchname} = $branches->{ $budget->{branchcode} }->{branchname}; $budget->{budget_hierarchy} = \@budget_hierarchy; } -- 2.39.5