Bugzilla – Attachment 89165 Details for
Bug 21036
Fix a bunch of older warnings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21036: Fix warnings from C4/Biblio
Bug-21036-Fix-warnings-from-C4Biblio.patch (text/plain), 3.86 KB, created by
Martin Renvoize (ashimema)
on 2019-05-01 09:43:17 UTC
(
hide
)
Description:
Bug 21036: Fix warnings from C4/Biblio
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-05-01 09:43:17 UTC
Size:
3.86 KB
patch
obsolete
>From 264a40a4635fdc35c297fb0d7efaf89d685b63e8 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 5 Jul 2018 09:53:57 +0200 >Subject: [PATCH] Bug 21036: Fix warnings from C4/Biblio > >Use of uninitialized value $isbn in string ne at /usr/share/koha/prodclone/C4/Biblio.pm line 1794. (16.11 line number) >Trivial edit. > >And these warnings from TransformHtmlToXml (with 16.11 line numbers): >Use of uninitialized value in substr at /usr/share/koha/prodclone/C4/Biblio.pm line 2527. >Use of uninitialized value in substr at /usr/share/koha/prodclone/C4/Biblio.pm line 2528. >substr outside of string at /usr/share/koha/prodclone/C4/Biblio.pm line 2528. >Indicator in 952 is empty at /usr/share/koha/prodclone/C4/Biblio.pm line 2534. > >The last warning is not needed and can be removed. >Note that the code used the construct @$indicator[$j] for $$indicator[$j]. >The first is an array slice. This worked in list context. But apparently >the second was meant to be used. And can be rewritten as $indicator->[$j] >which generally is considered more readable. >The code around indicator1/2 and ind1/2 is simplified. This change is applied >twice in the same sub. > >Test plan: >Read the changes. >Run t/Biblio/TransformHtmlToXml.t > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Biblio.pm | 28 +++++++--------------------- > 1 file changed, 7 insertions(+), 21 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index b769ab6cb0..958f7d9753 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1476,7 +1476,7 @@ sub GetMarcISBN { > my @marcisbns; > foreach my $field ( $record->field($scope) ) { > my $isbn = $field->subfield( 'a' ); >- if ( $isbn ne "" ) { >+ if ( $isbn && $isbn ne "" ) { > push @marcisbns, $isbn; > } > } >@@ -2172,16 +2172,9 @@ sub TransformHtmlToXml { > if ( ( @$tags[$i] ne $prevtag ) ) { > $close_last_tag = 0; > $j++ unless ( @$tags[$i] eq "" ); >- my $indicator1 = eval { substr( @$indicator[$j], 0, 1 ) }; >- my $indicator2 = eval { substr( @$indicator[$j], 1, 1 ) }; >- my $ind1 = _default_ind_to_space($indicator1); >- my $ind2; >- if ( @$indicator[$j] ) { >- $ind2 = _default_ind_to_space($indicator2); >- } else { >- warn "Indicator in @$tags[$i] is empty"; >- $ind2 = " "; >- } >+ my $str = ( $indicator->[$j] // q{} ) . ' '; # extra space prevents substr outside of string warn >+ my $ind1 = _default_ind_to_space( substr( $str, 0, 1 ) ); >+ my $ind2 = _default_ind_to_space( substr( $str, 1, 1 ) ); > if ( !$first ) { > $xml .= "</datafield>\n"; > if ( ( @$tags[$i] && @$tags[$i] > 10 ) >@@ -2214,19 +2207,12 @@ sub TransformHtmlToXml { > } > } > } else { # @$tags[$i] eq $prevtag >- my $indicator1 = eval { substr( @$indicator[$j], 0, 1 ) }; >- my $indicator2 = eval { substr( @$indicator[$j], 1, 1 ) }; >- my $ind1 = _default_ind_to_space($indicator1); >- my $ind2; >- if ( @$indicator[$j] ) { >- $ind2 = _default_ind_to_space($indicator2); >- } else { >- warn "Indicator in @$tags[$i] is empty"; >- $ind2 = " "; >- } > if ( @$values[$i] eq "" ) { > } else { > if ($first) { >+ my $str = ( $indicator->[$j] // q{} ) . ' '; # extra space prevents substr outside of string warn >+ my $ind1 = _default_ind_to_space( substr( $str, 0, 1 ) ); >+ my $ind2 = _default_ind_to_space( substr( $str, 1, 1 ) ); > $xml .= "<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n"; > $first = 0; > $close_last_tag = 1; >-- >2.20.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 21036
:
76686
|
76689
|
76702
|
76703
|
76704
|
78455
|
78456
|
88969
|
89164
| 89165 |
89166