Bugzilla – Attachment 4346 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
0007-Bug-5453-Move-declarations-out-of-conditionals.patch (text/plain), 13.98 KB, created by
Colin Campbell
on 2011-06-02 14:56:23 UTC
(
hide
)
Description:
Proposed Patch
Filename:
MIME Type:
Creator:
Colin Campbell
Created:
2011-06-02 14:56:23 UTC
Size:
13.98 KB
patch
obsolete
>From 8edda02e909a8e5a3f7e7306f1b753b5ac639dc7 Mon Sep 17 00:00:00 2001 >From: Colin Campbell <colin.campbell@ptfs-europe.com> >Date: Mon, 29 Nov 2010 17:53:22 +0000 >Subject: [PATCH 7/7] Bug 5453 : Move declarations out of conditionals >Content-Type: text/plain; charset="utf-8" > >Patched for C4 Modules >--- > C4/Auth.pm | 15 +++++---- > C4/Auth_with_ldap.pm | 5 ++- > C4/Biblio.pm | 81 ++++++++++++++++++++++++++++++++++++++----------- > C4/Budgets.pm | 5 ++- > C4/Letters.pm | 24 ++++++++------ > C4/Members.pm | 8 +++-- > C4/Record.pm | 17 +++++++--- > 7 files changed, 110 insertions(+), 45 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index b416449..f6f4fb8 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -137,12 +137,15 @@ sub get_template_and_user { > my $in = shift; > my $template = > gettemplate( $in->{'template_name'}, $in->{'type'}, $in->{'query'} ); >- my ( $user, $cookie, $sessionID, $flags ) = checkauth( >- $in->{'query'}, >- $in->{'authnotrequired'}, >- $in->{'flagsrequired'}, >- $in->{'type'} >- ) unless ($in->{'template_name'}=~/maintenance/); >+ my ( $user, $cookie, $sessionID, $flags ); >+ if ( $in->{'template_name'} !~m/maintenance/ ) { >+ ( $user, $cookie, $sessionID, $flags ) = checkauth( >+ $in->{'query'}, >+ $in->{'authnotrequired'}, >+ $in->{'flagsrequired'}, >+ $in->{'type'} >+ ); >+ } > > my $borrowernumber; > my $insecure = C4::Context->preference('insecure'); >diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm >index acbd923..417c6f5 100644 >--- a/C4/Auth_with_ldap.pm >+++ b/C4/Auth_with_ldap.pm >@@ -165,8 +165,9 @@ sub checkpw_ldap { > if (C4::Context->preference('ExtendedPatronAttributes') && $borrowernumber && ($config{update} ||$config{replicate})) { > my @types = C4::Members::AttributeTypes::GetAttributeTypes(); > my @attributes = grep{my $key=$_; any{$_ eq $key}@types;} keys %borrower; >- my $extended_patron_attributes = map{{code=>$_,value=>$borrower{$_}}}@attributes; >- my $extended_patron_attributes = [] unless $extended_patron_attributes; >+ my $extended_patron_attributes; >+ @{$extended_patron_attributes} = >+ map { { code => $_, value => $borrower{$_} } } @attributes; > my @errors; > #Check before add > for (my $i; $i< scalar(@$extended_patron_attributes)-1;$i++) { >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 016b53d..5fa31ee 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1510,7 +1510,10 @@ sub GetMarcSubjects { > my $value = $subject_subfield->[1]; > my $linkvalue = $value; > $linkvalue =~ s/(\(|\))//g; >- my $operator = " and " unless $counter == 0; >+ my $operator; >+ if ( $counter != 0 ) { >+ $operator = ' and '; >+ } > if ( $code eq 9 ) { > $found9 = 1; > @link_loop = ( { 'limit' => 'an', link => "$linkvalue" } ); >@@ -1518,7 +1521,10 @@ sub GetMarcSubjects { > if ( not $found9 ) { > push @link_loop, { 'limit' => $subject_limit, link => $linkvalue, operator => $operator }; > } >- my $separator = C4::Context->preference("authoritysep") unless $counter == 0; >+ my $separator; >+ if ( $counter != 0 ) { >+ $separator = C4::Context->preference('authoritysep'); >+ } > > # ignore $9 > my @this_link_loop = @link_loop; >@@ -1576,7 +1582,10 @@ sub GetMarcAuthors { > my $value = $authors_subfield->[1]; > my $linkvalue = $value; > $linkvalue =~ s/(\(|\))//g; >- my $operator = " and " unless $count_auth == 0; >+ my $operator; >+ if ( $count_auth != 0 ) { >+ $operator = ' and '; >+ } > > # if we have an authority link, use that as the link, otherwise use standard searching > if ($subfield9) { >@@ -1592,8 +1601,17 @@ sub GetMarcAuthors { > $value = GetAuthorisedValueDesc( $field->tag(), $authors_subfield->[0], $authors_subfield->[1], '', $tagslib ) > if ( $marcflavour eq 'UNIMARC' and ( $authors_subfield->[0] =~ /4/ ) ); > my @this_link_loop = @link_loop; >- my $separator = C4::Context->preference("authoritysep") unless $count_auth == 0; >- push @subfields_loop, { code => $subfieldcode, value => $value, link_loop => \@this_link_loop, separator => $separator } unless ( $authors_subfield->[0] eq '9' ); >+ my $separator; >+ if ( $count_auth != 0 ) { >+ $separator = C4::Context->preference('authoritysep'); >+ } >+ push @subfields_loop, >+ { code => $subfieldcode, >+ value => $value, >+ link_loop => \@this_link_loop, >+ separator => $separator >+ } >+ unless ( $authors_subfield->[0] eq '9' ); > $count_auth++; > } > push @marcauthors, { MARCAUTHOR_SUBFIELDS_LOOP => \@subfields_loop }; >@@ -1704,13 +1722,27 @@ sub GetMarcSeries { > my $value = $series_subfield->[1]; > my $linkvalue = $value; > $linkvalue =~ s/(\(|\))//g; >- my $operator = " and " unless $counter == 0; >- push @link_loop, { link => $linkvalue, operator => $operator }; >- my $separator = C4::Context->preference("authoritysep") unless $counter == 0; >+ if ( $counter != 0 ) { >+ push @link_loop, { link => $linkvalue, operator => ' and ', }; >+ } else { >+ push @link_loop, { link => $linkvalue, operator => undef, }; >+ } >+ my $separator; >+ if ( $counter != 0 ) { >+ $separator = C4::Context->preference('authoritysep'); >+ } > if ($volume_number) { > push @subfields_loop, { volumenum => $value }; > } else { >- push @subfields_loop, { code => $code, value => $value, link_loop => \@link_loop, separator => $separator, volumenum => $volume_number } unless ( $series_subfield->[0] eq '9' ); >+ if ( $series_subfield->[0] ne '9' ) { >+ push @subfields_loop, { >+ code => $code, >+ value => $value, >+ link_loop => \@link_loop, >+ separator => $separator, >+ volumenum => $volume_number, >+ }; >+ } > } > $counter++; > } >@@ -2326,8 +2358,11 @@ sub PrepareItemrecordDisplay { > my $tagslib = &GetMarcStructure( 1, $frameworkcode ); > > # return nothing if we don't have found an existing framework. >- return "" unless $tagslib; >- my $itemrecord = C4::Items::GetMarcItem( $bibnum, $itemnum ) if ($itemnum); >+ return q{} unless $tagslib; >+ my $itemrecord; >+ if ($itemnum) { >+ $itemrecord = C4::Items::GetMarcItem( $bibnum, $itemnum ); >+ } > my @loop_data; > my $authorised_values_sth = $dbh->prepare( "SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib" ); > foreach my $tag ( sort keys %{$tagslib} ) { >@@ -2366,15 +2401,20 @@ sub PrepareItemrecordDisplay { > && C4::Context->preference('itemcallnumber') ) { > my $CNtag = substr( C4::Context->preference('itemcallnumber'), 0, 3 ); > my $CNsubfield = substr( C4::Context->preference('itemcallnumber'), 3, 1 ); >- my $temp = $itemrecord->field($CNtag) if ($itemrecord); >- if ($temp) { >- $defaultvalue = $temp->subfield($CNsubfield); >+ if ($itemrecord) { >+ my $temp = $itemrecord->field($CNtag); >+ if ($temp) { >+ $defaultvalue = $temp->subfield($CNsubfield); >+ } > } > } > if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber' > && $defaultvalues > && $defaultvalues->{'callnumber'} ) { >- my $temp = $itemrecord->field($subfield) if ($itemrecord); >+ my $temp; >+ if ($itemrecord) { >+ $temp = $itemrecord->field($subfield); >+ } > unless ($temp) { > $defaultvalue = $defaultvalues->{'callnumber'} if $defaultvalues; > } >@@ -2382,7 +2422,10 @@ sub PrepareItemrecordDisplay { > if ( ( $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.holdingbranch' || $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.homebranch' ) > && $defaultvalues > && $defaultvalues->{'branchcode'} ) { >- my $temp = $itemrecord->field($subfield) if ($itemrecord); >+ my $temp; >+ if ($itemrecord) { >+ $temp = $itemrecord->field($subfield); >+ } > unless ($temp) { > $defaultvalue = $defaultvalues->{branchcode} if $defaultvalues; > } >@@ -2507,8 +2550,10 @@ sub PrepareItemrecordDisplay { > } > } > } >- my $itemnumber = $itemrecord->subfield( $itemtagfield, $itemtagsubfield ) >- if ( $itemrecord && $itemrecord->field($itemtagfield) ); >+ my $itemnumber; >+ if ( $itemrecord && $itemrecord->field($itemtagfield) ) { >+ $itemnumber = $itemrecord->subfield( $itemtagfield, $itemtagsubfield ); >+ } > return { > 'itemtagfield' => $itemtagfield, > 'itemtagsubfield' => $itemtagsubfield, >diff --git a/C4/Budgets.pm b/C4/Budgets.pm >index d2010d0..d516a12 100644 >--- a/C4/Budgets.pm >+++ b/C4/Budgets.pm >@@ -590,7 +590,10 @@ sub GetBudgetHierarchy { > # add budget-percent and allocation, and flags for html-template > foreach my $r (@sort) { > my $subs_href = $r->{'child'}; >- my @subs_arr = @$subs_href if defined $subs_href; >+ my @subs_arr = (); >+ if ( defined $subs_href ) { >+ @subs_arr = @{$subs_href}; >+ } > > my $moo = $r->{'budget_code_indent'}; > $moo =~ s/\ /\ \;/g; >diff --git a/C4/Letters.pm b/C4/Letters.pm >index c894a57..cb47c7e 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -323,12 +323,14 @@ sub SendAlerts { > $letter->{content} =~ s/<<LibrarianSurname>>/$userenv->{surname}/g; > $letter->{content} =~ > s/<<LibrarianEmailaddress>>/$userenv->{emailaddress}/g; >- foreach my $data (@$dataorders) { >- my $line = $1 if ( $letter->{content} =~ m/(<<.*>>)/ ); >- foreach my $field ( keys %$data ) { >- $line =~ s/(<<[^\.]+.$field>>)/$data->{$field}/; >+ foreach my $data ( @{$dataorders} ) { >+ if ( $letter->{content} =~ m/(<<.*>>)/ ) { >+ my $line = $1; >+ foreach my $field ( keys %{$data} ) { >+ $line =~ s/(<<[^\.]+.$field>>)/$data->{$field}/; >+ } >+ $letter->{content} =~ s/(<<.*>>)/$line\n$1/; > } >- $letter->{content} =~ s/(<<.*>>)/$line\n$1/; > } > $letter->{content} =~ s/<<[^>]*>>//g; > my $innerletter = $letter; >@@ -391,12 +393,14 @@ sub SendAlerts { > $letter->{content} =~ s/<<LibrarianSurname>>/$userenv->{surname}/g; > $letter->{content} =~ > s/<<LibrarianEmailaddress>>/$userenv->{emailaddress}/g; >- foreach my $data (@$dataorders) { >- my $line = $1 if ( $letter->{content} =~ m/(<<.*>>)/ ); >- foreach my $field ( keys %$data ) { >- $line =~ s/(<<[^\.]+.$field>>)/$data->{$field}/; >+ foreach my $data ( @{$dataorders} ) { >+ if ( $letter->{content} =~ m/(<<.*>>)/ ) { >+ my $line = $1; >+ foreach my $field ( keys %{$data} ) { >+ $line =~ s/(<<[^\.]+.$field>>)/$data->{$field}/; >+ } >+ $letter->{content} =~ s/(<<.*>>)/$line\n$1/; > } >- $letter->{content} =~ s/(<<.*>>)/$line\n$1/; > } > $letter->{content} =~ s/<<[^>]*>>//g; > my $innerletter = $letter; >diff --git a/C4/Members.pm b/C4/Members.pm >index e03b40b..16b1745 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -1167,9 +1167,11 @@ sub GetMemberAccountRecords { > $sth->execute( @bind ); > my $total = 0; > while ( my $data = $sth->fetchrow_hashref ) { >- my $biblio = GetBiblioFromItemNumber($data->{itemnumber}) if $data->{itemnumber}; >- $data->{biblionumber} = $biblio->{biblionumber}; >- $data->{title} = $biblio->{title}; >+ if ( $data->{itemnumber} ) { >+ my $biblio = GetBiblioFromItemNumber( $data->{itemnumber} ); >+ $data->{biblionumber} = $biblio->{biblionumber}; >+ $data->{title} = $biblio->{title}; >+ } > $acctlines[$numlines] = $data; > $numlines++; > $total += int(1000 * $data->{'amountoutstanding'}); # convert float to integer to avoid round-off errors >diff --git a/C4/Record.pm b/C4/Record.pm >index c5727f3..cecb6ed 100644 >--- a/C4/Record.pm >+++ b/C4/Record.pm >@@ -266,12 +266,19 @@ sub marc2modsxml { > sub marc2endnote { > my ($marc) = @_; > my $marc_rec_obj = MARC::Record->new_from_usmarc($marc); >- my $f260 = $marc_rec_obj->field('260'); >- my $f260a = $f260->subfield('a') if $f260; >+ my ( $abstract, $f260a, $f710a ); >+ my $f260 = $marc_rec_obj->field('260'); >+ if ($f260) { >+ $f260a = $f260->subfield('a') if $f260; >+ } > my $f710 = $marc_rec_obj->field('710'); >- my $f710a = $f710->subfield('a') if $f710; >- my $f500 = $marc_rec_obj->field('500'); >- my $abstract = $f500->subfield('a') if $f500; >+ if ($f710) { >+ $f710a = $f710->subfield('a'); >+ } >+ my $f500 = $marc_rec_obj->field('500'); >+ if ($f500) { >+ $abstract = $f500->subfield('a'); >+ } > my $fields = { > DB => C4::Context->preference("LibraryName"), > Title => $marc_rec_obj->title(), >-- >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