Bugzilla – Attachment 4345 Details for
Bug 5453
Variables declaration should not occur in conditionals
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed Patch
0006-Bug-5453-Move-declarations-out-of-conditionals.patch (text/plain), 8.77 KB, created by
Colin Campbell
on 2011-06-02 14:55:40 UTC
(
hide
)
Description:
Proposed Patch
Filename:
MIME Type:
Creator:
Colin Campbell
Created:
2011-06-02 14:55:40 UTC
Size:
8.77 KB
patch
obsolete
>From ec30e9de09d8ad4d4443265db1a20f2edbdb8100 Mon Sep 17 00:00:00 2001 >From: Colin Campbell <colin.campbell@ptfs-europe.com> >Date: Mon, 29 Nov 2010 15:19:22 +0000 >Subject: [PATCH 6/7] Bug 5453 Move declarations out of conditionals >Content-Type: text/plain; charset="utf-8" > >--- > cataloguing/addbiblio.pl | 5 ++++- > reports/issues_avg_stats.pl | 35 +++++++++++++++++++++++++++-------- > suggestion/suggestion.pl | 12 +++++++++--- > tools/export.pl | 17 +++++++++-------- > tools/holidays.pl | 20 +++++++++++--------- > tools/picture-upload.pl | 12 +++++++++--- > 6 files changed, 69 insertions(+), 32 deletions(-) > >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index 7e146c0..90455a7 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -917,7 +917,10 @@ if ( $op eq "addbiblio" ) { > my @params = $input->param(); > $record = TransformHtmlToMarc( \@params , $input ); > # check for a duplicate >- my ($duplicatebiblionumber,$duplicatetitle) = FindDuplicate($record) if (!$is_a_modif); >+ my ( $duplicatebiblionumber, $duplicatetitle ); >+ if ( !$is_a_modif ) { >+ ( $duplicatebiblionumber, $duplicatetitle ) = FindDuplicate($record); >+ } > my $confirm_not_duplicate = $input->param('confirm_not_duplicate'); > # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate) > if ( !$duplicatebiblionumber or $confirm_not_duplicate ) { >diff --git a/reports/issues_avg_stats.pl b/reports/issues_avg_stats.pl >index f0f1dd5..c6a3859 100755 >--- a/reports/issues_avg_stats.pl >+++ b/reports/issues_avg_stats.pl >@@ -554,8 +554,23 @@ sub calculate { > # and the number matches the number of columns > my $colcount=0; > foreach my $col ( @loopcol ) { >- my $value =$table{$row}->{(($col->{coltitle} eq "NULL")or ($col->{coltitle} eq ""))?"zzEMPTY":$col->{coltitle}} / $wgttable{$row}->{(($col->{coltitle} eq "NULL")or ($col->{coltitle} eq ""))?"zzEMPTY":$col->{coltitle}} if ($table{$row}->{(($col->{coltitle} eq "NULL")or ($col->{coltitle} eq ""))?"zzEMPTY":$col->{coltitle}}); >- >+ my $value; >+ if ($table{$row}->{ >+ ( ( $col->{coltitle} eq 'NULL' ) >+ or ( $col->{coltitle} eq q{} ) >+ ) ? 'zzEMPTY' : $col->{coltitle} >+ } >+ ) { >+ $value = $table{$row}->{ >+ ( ( $col->{coltitle} eq 'NULL' ) >+ or ( $col->{coltitle} eq q{} ) >+ ) ? 'zzEMPTY' : $col->{coltitle} >+ } / $wgttable{$row}->{ >+ ( ( $col->{coltitle} eq 'NULL' ) >+ or ( $col->{coltitle} eq q{} ) >+ ) ? 'zzEMPTY' : $col->{coltitle} >+ }; >+ } > $table{$row}->{(($col->{coltitle} eq "NULL")or ($col->{coltitle} eq ""))?"zzEMPTY":$col->{coltitle}} = $value; > $table{$row}->{totalrow}+=$value; > #warn "row : $row col:$col $cnttable{$row}->{(($col->{coltitle} eq \"NULL\")or ($col->{coltitle} eq \"\"))?\"zzEMPTY\":$col->{coltitle}}"; >@@ -563,12 +578,16 @@ sub calculate { > push @loopcell, {value => ($value)?sprintf("%.2f",$value):0 } ; > } > #warn "row : $row colcount:$colcount"; >- my $total = $table{$row}->{totalrow}/$colcount if ($colcount>0); >- push @looprow,{ 'rowtitle' => ($row eq "zzEMPTY")?"NULL":$row, >- 'loopcell' => \@loopcell, >- 'hilighted' => ($hilighted >0), >- 'totalrow' => ($total)?sprintf("%.2f",$total):0 >- }; >+ my $total; >+ if ( $colcount > 0 ) { >+ $total = $table{$row}->{totalrow} / $colcount; >+ } >+ push @looprow, >+ { 'rowtitle' => ( $row eq "zzEMPTY" ) ? "NULL" : $row, >+ 'loopcell' => \@loopcell, >+ 'hilighted' => ( $hilighted > 0 ), >+ 'totalrow' => ($total) ? sprintf( "%.2f", $total ) : 0 >+ }; > $hilighted = -$hilighted; > } > # >diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl >index aa8fad0..d00b632 100755 >--- a/suggestion/suggestion.pl >+++ b/suggestion/suggestion.pl >@@ -288,10 +288,16 @@ my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG",$$suggestion_ref{'patron > $template->param(patron_reason_loop=>$patron_reason_loop); > > #Budgets management >-my $searchbudgets={ budget_branchcode=>$branchfilter} if $branchfilter; >-my $budgets = GetBudgets($searchbudgets); >+my $budgets = []; >+if ($branchfilter) { >+ my $searchbudgets = { budget_branchcode => $branchfilter }; >+ $budgets = GetBudgets($searchbudgets); >+} else { >+ $budgets = GetBudgets(undef); >+} > >-foreach my $budget (@$budgets){ >+foreach my $budget ( @{$budgets} ) { >+## Please see file perltidy.ERR > $budget->{'selected'}=1 if ($$suggestion_ref{'budgetid'} && $budget->{'budget_id'} eq $$suggestion_ref{'budgetid'}) > }; > >diff --git a/tools/export.pl b/tools/export.pl >index d858f44..4a09868 100755 >--- a/tools/export.pl >+++ b/tools/export.pl >@@ -184,16 +184,17 @@ else { > push @itemtypesloop, \%row; > } > my @branchloop; >- for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) { >- my $selected = 1 if $thisbranch eq $branch; >- my %row = ( >- value => $thisbranch, >- selected => $selected, >+ for my $thisbranch ( >+ sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } >+ keys %{$branches} >+ ) { >+ push @branchloop, >+ { value => $thisbranch, >+ selected => $thisbranch eq $branch, > branchname => $branches->{$thisbranch}->{'branchname'}, >- ); >- push @branchloop, \%row; >+ }; > } >- >+ > $template->param( > branchloop => \@branchloop, > itemtypeloop => \@itemtypesloop, >diff --git a/tools/holidays.pl b/tools/holidays.pl >index eb3bc9c..90ef56a 100755 >--- a/tools/holidays.pl >+++ b/tools/holidays.pl >@@ -65,18 +65,20 @@ if ( $onlymine ) { > $branch = C4::Context->userenv->{'branch'}; > } > my $branchname = GetBranchName($branch); >-my $branches = GetBranches($onlymine); >+my $branches = GetBranches($onlymine); > my @branchloop; >-for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) { >- my $selected = 1 if $thisbranch eq $branch; >- my %row =(value => $thisbranch, >- selected => $selected, >- branchname => $branches->{$thisbranch}->{'branchname'}, >- ); >- push @branchloop, \%row; >+for my $thisbranch ( >+ sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } >+ keys %{$branches} ) { >+ push @branchloop, >+ { value => $thisbranch, >+ selected => $thisbranch eq $branch, >+ branchname => $branches->{$thisbranch}->{'branchname'}, >+ }; > } >+ > # branches calculated - put branch codes in a single string so they can be passed in a form >-my $branchcodes = join("|", keys %$branches); >+my $branchcodes = join '|', keys %{$branches}; > > # Get all the holidays > >diff --git a/tools/picture-upload.pl b/tools/picture-upload.pl >index f4c75d8..bfb233e 100755 >--- a/tools/picture-upload.pl >+++ b/tools/picture-upload.pl >@@ -78,7 +78,10 @@ my ( $total, $handled, @counts, $tempfile, $tfh ); > if ( ($op eq 'Upload') && $uploadfile ) { # Case is important in these operational values as the template must use case to be visually pleasing! > my $dirname = File::Temp::tempdir( CLEANUP => 1); > $debug and warn "dirname = $dirname"; >- my $filesuffix = $1 if $uploadfilename =~ m/(\..+)$/i; >+ my $filesuffix; >+ if ( $uploadfilename =~ m/(\..+)$/i ) { >+ my $filesuffix = $1; >+ } > ( $tfh, $tempfile ) = File::Temp::tempfile( SUFFIX => $filesuffix, UNLINK => 1 ); > $debug and warn "tempfile = $tempfile"; > my ( @directories, $errors ); >@@ -254,8 +257,11 @@ sub handle_file { > undef $srcimage; # This object can get big... > } > $debug and warn "Image is of mimetype $mimetype"; >- my $dberror = PutPatronImage($cardnumber,$mimetype, $imgfile) if $mimetype; >- if ( !$dberror && $mimetype ) { # Errors from here on are fatal only to the import of a particular image, so don't bail, just note the error and keep going >+ my $dberror; >+ if ($mimetype) { >+ $dberror = PutPatronImage( $cardnumber, $mimetype, $imgfile ); >+ } >+ if ( !$dberror && $mimetype ) { # Errors from here on are fatal only to the import of a particular image, so don't bail, just note the error and keep going > $count{count}++; > push @{ $count{filenames} }, { source => $filename, cardnumber => $cardnumber }; > } elsif ( $dberror ) { >-- >1.7.5.2 >
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 5453
:
4340
|
4341
|
4342
|
4343
|
4344
|
4345
|
4346
|
4455
|
4456
|
4457
|
4458
|
4459
|
4460
|
4461