From b67d77e2110052de588fbd99329131342e913e3e Mon Sep 17 00:00:00 2001 From: Paul POULAIN Date: Wed, 12 Sep 2007 15:59:58 +0200 Subject: [PATCH] BUGFIX : repeated fields where merged on biblio update When updating a biblio, all repeated fields had the same input name. Thus, when retrieving them through cgi->param resulted in a single line Thus all subfields where merged in a single MARC field. Adding a random() part to the name solves the problem + removing some warn lines Signed-off-by: Chris Cormack --- C4/Biblio.pm | 3 +-- cataloguing/addbiblio.pl | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 815cae5b35..b335ce2ffa 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2225,7 +2225,6 @@ sub TransformHtmlToMarc { my $record = MARC::Record->new(); my $i=0; my @fields; - while ($params->[$i]){ # browse all CGI params my $param = $params->[$i]; my $newfield=0; @@ -2253,7 +2252,7 @@ sub TransformHtmlToMarc { my $ind1 = substr($cgi->param($param),0,1); my $ind2 = substr($cgi->param($param),1,1); - + $newfield=0; my $j=$i+1; if($tag < 10){ # no code for theses fields diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 0833c3faea..39c803c616 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -466,6 +466,7 @@ sub build_tabs ($$$$$) { else { push @fields, $record->leader(); # if tag == 000 } + # loop through each field foreach my $field (@fields) { my @subfields_data; @@ -528,6 +529,10 @@ sub build_tabs ($$$$$) { ); } if ( $#subfields_data >= 0 ) { + # build the tag entry. + # note that the random() field is mandatory. Otherwise, on repeated fields, you'll + # have twice the same "name" value, and cgi->param() will return only one, making + # all subfields to be merged in a single field. my %tag_data = ( tag => $tag, index => $index_tag, @@ -535,6 +540,7 @@ sub build_tabs ($$$$$) { repeatable => $tagslib->{$tag}->{repeatable}, subfield_loop => \@subfields_data, fixedfield => ($tag < 10)?(1):(0), + random => CreateKey, ); if ($tag >= 010){ # no indicator for theses tag $tag_data{indicator} = $field->indicator(1).$field->indicator(2); @@ -604,14 +610,12 @@ AND (authtypecode IS NOT NULL AND authtypecode<>\"\")|); $query->execute($frameworkcode); my ($countcreated,$countlinked); while (my $data=$query->fetchrow_hashref){ - warn Data::Dumper::Dumper($data); if ($record->field($data->{tagfield})){ next if ($record->subfield($data->{tagfield},'3')||$record->subfield($data->{tagfield},'9')); # No authorities id in the tag. # Search if there is any authorities to link to. my $query='at='.$data->{authtypecode}.' '; map {$query.= " and he=".$_->[1] if ($_->[0]=~/[A-z]/)} $record->field($data->{tagfield})->subfields(); - warn $query; my ($error,$results)=SimpleSearch($query,"authorityserver"); # there is at least 1 result => return the 1st one if (@$results>1) { -- 2.20.1