From 385ffe517940aa8cfdc65b363b9f54ef7e6a5ed7 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Wed, 19 Nov 2008 14:58:23 +0100 Subject: [PATCH] Merging authorities caused an encoding problem in biblios MARC::File::USMARC::decode is not aware of encoding as MARC::File::XML is So it caused a problem when decoding information and updating biblios. Now uses MARC::File::XML Encoding is OK Signed-off-by: Galen Charlton --- C4/AuthoritiesMarc.pm | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 5d2d5a817e..2d3caead50 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -1219,6 +1219,7 @@ sub merge { } else { #zebra connection my $oConnection=C4::Context->Zconn("biblioserver",0); + $oConnection->option("preferredRecordSyntax"=>"XML"); my $query; $query= "an=".$mergefrom; my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection )); @@ -1253,31 +1254,38 @@ sub merge { # May be used as a template for a bulkedit field foreach my $marcrecord(@reccache){ my $update; - $marcrecord= MARC::File::USMARC::decode($marcrecord) unless(C4::Context->preference('NoZebra')); + $marcrecord= MARC::Record->new_from_xml($marcrecord,"utf8",C4::Context->preference("marcflavour")) unless(C4::Context->preference('NoZebra')); foreach my $tagfield (@tags_using_authtype){ + warn "tagfield : $tagfield "; foreach my $field ($marcrecord->field($tagfield)){ my $auth_number=$field->subfield("9"); my $tag=$field->tag(); if ($auth_number==$mergefrom) { - my $field_to=MARC::Field->new(($tag_to?$tag_to:$tag),$field->indicator(1),$field->indicator(2),"9"=>$mergeto); - foreach my $subfield (@record_to) { - $field_to->add_subfields($subfield->[0] =>$subfield->[1]); - } - $marcrecord->delete_field($field); - $marcrecord->insert_grouped_field($field_to); - $update=1; + my $field_to=MARC::Field->new(($tag_to?$tag_to:$tag),$field->indicator(1),$field->indicator(2),"9"=>$mergeto); + foreach my $subfield (@record_to) { + $field_to->add_subfields($subfield->[0] =>$subfield->[1]); + } + $marcrecord->delete_field($field); + $marcrecord->insert_grouped_field($field_to); + $update=1; } }#for each tag }#foreach tagfield - my $oldbiblio = TransformMarcToKoha($dbh,$marcrecord,"") ; + my ($bibliotag,$bibliosubf) = GetMarcFromKohaField("biblio.biblionumber","") ; + my $biblionumber=$marcrecord->subfield($bibliotag,$bibliosubf); + unless ($biblionumber){ + warn "pas de numéro de notice bibliographique dans : ".$marcrecord->as_formatted; + next; + } if ($update==1){ - &ModBiblio($marcrecord,$oldbiblio->{'biblionumber'},GetFrameworkCode($oldbiblio->{'biblionumber'})) ; + &ModBiblio($marcrecord,$biblionumber,GetFrameworkCode($biblionumber)) ; $counteditedbiblio++; warn $counteditedbiblio if (($counteditedbiblio % 10) and $ENV{DEBUG}); } }#foreach $marc return $counteditedbiblio; # now, find every other authority linked with this authority + # now, find every other authority linked with this authority # my $oConnection=C4::Context->Zconn("authorityserver"); # my $query; # # att 9210 Auth-Internal-authtype -- 2.39.5