From 28ad0ab51321955878082d363be2210589a8261f Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 24 Jun 2016 11:29:19 -0400 Subject: [PATCH] Bug 16809: Silence authority warnings C4::Biblio::TransformHtmlToMarc Most of the floodiness is caused by accessing the cgi parameters in a context which is hard to determine. By purposefully saving the value to a scalar variable and using the variable, the issue disappears, and it will likely be a tiny tad faster as variable access is faster than multiple function calls. TEST PLAN --------- 1) Back up your intranet error log -- for example: cp ~/koha-dev/var/log/koha-error-log ~/koha-error-log.backup 2) Blank your intranet error log -- for example: echo > ~/koha-dev/var/log/koha-error-log 3) Log into your staff client 4) Click 'Authorities' 5) Click 'New from Z39.50' 5) Type 'Seuss' into 'Name (any):' and press enter 6) Click 'Import' beside the first link 7) Click 'Save' 8) Check your koha-error-log -- floody! 9) Apply patch 10) repeat steps 2-8 -- blank! 11) restore your intranet error log -- for example: mv ~/koha-error-log.backup ~/koha-dev/var/log/koha-error-log 12) run koha qa test tools Signed-off-by: Marcel de Rooy Tested with addbiblio.pl. I would have preferred the scalar option in terms of simpler code, but this works too. Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- C4/Biblio.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 2798325be1..3c99638e90 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2574,18 +2574,19 @@ sub TransformHtmlToMarc { if ( $tag < 10 ) { # no code for theses fields # in MARC editor, 000 contains the leader. next if $tag == $biblionumbertagfield; + my $fval= $cgi->param($params[$j+1]); if ( $tag eq '000' ) { # Force a fake leader even if not provided to avoid crashing # during decoding MARC record containing UTF-8 characters $record->leader( - length( $cgi->param($params[$j+1]) ) == 24 - ? $cgi->param( $params[ $j + 1 ] ) + length( $fval ) == 24 + ? $fval : ' nam a22 4500' ) ; # between 001 and 009 (included) - } elsif ( $cgi->param( $params[ $j + 1 ] ) ne '' ) { - $newfield = MARC::Field->new( $tag, $cgi->param( $params[ $j + 1 ] ), ); + } elsif ( $fval ne '' ) { + $newfield = MARC::Field->new( $tag, $fval, ); } # > 009, deal with subfields @@ -2599,13 +2600,14 @@ sub TransformHtmlToMarc { #if next param ne subfield, then it was probably empty #try next param by incrementing j if($params[$j+1]!~/_subfield_/) {$j++; next; } + my $fkey= $cgi->param($params[$j]); my $fval= $cgi->param($params[$j+1]); #check if subfield value not empty and field exists if($fval ne '' && $newfield) { - $newfield->add_subfields( $cgi->param($params[$j]) => $fval); + $newfield->add_subfields( $fkey => $fval); } elsif($fval ne '') { - $newfield = MARC::Field->new( $tag, $ind1, $ind2, $cgi->param($params[$j]) => $fval ); + $newfield = MARC::Field->new( $tag, $ind1, $ind2, $fkey => $fval ); } $j += 2; } #end-of-while -- 2.39.5