This commit fixes a bug in biblio encoding. things were mixed up when reporting item(s) into the biblio, to UPDATE biblioitems.marcxml, after a biblio modif (in MARC editor).

So, deal carefully with this commit pls, and check it for your setups, because the patch works for me, but I'm not sure to understand well why :\

Signed-off-by: Chris Cormack <crc@liblime.com>
This commit is contained in:
Paul POULAIN 2007-08-14 19:02:57 +02:00 committed by Chris Cormack
parent fc41d057f1
commit 9a32fe85c2
2 changed files with 28 additions and 30 deletions

View file

@ -20,7 +20,7 @@ package C4::Biblio;
use strict;
require Exporter;
use utf8;
# use utf8;
use C4::Context;
use MARC::Record;
use MARC::File::USMARC;
@ -371,15 +371,24 @@ sub ModBiblio {
# get the items before and append them to the biblio before updating the record, atm we just have the biblio
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",$frameworkcode);
my $oldRecord = GetMarcBiblio( $biblionumber );
#$oldRecord->encoding('UTF-8');
my @fields = $oldRecord->field( $itemtag );
foreach (@fields){
if ( !utf8::is_utf8( $_ ) ) {
utf8::decode( $_ );
}
# parse each item, and, for an unknown reason, re-encode each subfield
# if you don't do that, the record will have encoding mixed
# and the biblio will be re-encoded.
# strange, I (Paul P.) searched more than 1 day to understand what happends
# but could only solve the problem this way...
my @fields = $oldRecord->field( $itemtag );
foreach my $fielditem ( @fields ){
my $field;
foreach ($fielditem->subfields()) {
if ($field) {
$field->add_subfields(Encode::encode('utf-8',$_->[0]) => Encode::encode('utf-8',$_->[1]));
} else {
$field = MARC::Field->new("$itemtag",'','',Encode::encode('utf-8',$_->[0]) => Encode::encode('utf-8',$_->[1]));
}
}
$record->append_fields($field);
}
$record->append_fields( @fields ); # FIXME : encoding error...
# adding biblionumber
my ($tag_biblionumber, $subfield_biblionumber) = GetMarcFromKohaField('biblio.biblionumber',$frameworkcode);
@ -465,22 +474,6 @@ sub ModItemTransfer {
return;
}
##New sub to dotransfer in marc tables as well. Not exported -TG 10/04/2006
# sub domarctransfer {
# my ( $dbh, $itemnumber ) = @_;
# $itemnumber =~ s /\'//g; ##itemnumber seems to come with quotes-TG
# my $sth =
# $dbh->prepare(
# "select biblionumber,holdingbranch from items where itemnumber=$itemnumber"
# );
# $sth->execute();
# while ( my ( $biblionumber, $holdingbranch ) = $sth->fetchrow ) {
# &ModItemInMarconefield( $biblionumber, $itemnumber,
# 'items.holdingbranch', $holdingbranch );
# }
# return;
# }
=head2 ModBiblioframework
ModBiblioframework($biblionumber,$frameworkcode);
@ -2233,11 +2226,17 @@ sub TransformHtmlToMarc {
my $j=$i+1;
if($tag < 10){ # no code for theses fields
my $inner_param = $params->[$j];
$newfield = MARC::Field->new(
$tag,
$cgi->param($params->[$j+1]),
);
# in MARC editor, 000 contains the leader.
if ($tag eq '000' ) {
$record->leader($cgi->param($params->[$j+1])) if length($cgi->param($params->[$j+1]))==24;
# between 001 and 009 (included)
} else {
$newfield = MARC::Field->new(
$tag,
$cgi->param($params->[$j+1]),
);
}
# > 009, deal with subfields
} else {
while($params->[$j] =~ /_code_/){ # browse all it's subfield
my $inner_param = $params->[$j];

View file

@ -68,7 +68,6 @@ my $frameworkcode = &GetFrameworkCode($biblionumber);
my $tagslib = &GetMarcStructure(1,$frameworkcode);
my $record = GetMarcBiblio($biblionumber);
warn "==>".$record->as_formatted;
my $oldrecord = TransformMarcToKoha($dbh,$record);
my $itemrecord;
my $nextop="additem";