From e5bbeace3dd83b73e5d6384bb196e5434d68d004 Mon Sep 17 00:00:00 2001 From: tipaul Date: Mon, 28 Apr 2003 13:07:14 +0000 Subject: [PATCH] Those fixes solves the "internal server error" with MARC::Record 1.12. It was due to an illegal contruction in Koha : we tried to retrive subfields from <10 tags. That's not possible. MARC::Record accepted this in 0.93 version, but it was fixed after. Now, the construct/retrieving is OK ! --- C4/Biblio.pm | 12 ++++++++---- MARCdetail.pl | 37 ++++++++++++++++++++----------------- acqui.simple/additem.pl | 2 +- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 28984991b4..d14fcc4adb 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1,6 +1,12 @@ package C4::Biblio; # $Id$ # $Log$ +# Revision 1.44 2003/04/28 13:07:14 tipaul +# Those fixes solves the "internal server error" with MARC::Record 1.12. +# It was due to an illegal contruction in Koha : we tried to retrive subfields from <10 tags. +# That's not possible. MARC::Record accepted this in 0.93 version, but it was fixed after. +# Now, the construct/retrieving is OK ! +# # Revision 1.43 2003/04/10 13:56:02 tipaul # Fix some bugs : # * worked in 1.9.0, but not in 1.9.1 : @@ -631,9 +637,9 @@ sub MARCgetbiblio { if ($row->{tagorder} ne $prevtagorder || $row->{tag} ne $prevtag) { $previndicator.=" "; if ($prevtag <10) { - $record->add_fields((sprintf "%03s",$prevtag),$prevvalue); + $record->add_fields((sprintf "%03s",$prevtag),$prevvalue) unless $prevtag eq "XXX"; # ignore the 1st loop } else { - $record->add_fields($field); + $record->add_fields($field) unless $prevtag eq "XXX"; } undef $field; $prevtagorder=$row->{tagorder}; @@ -749,8 +755,6 @@ sub MARCmoditem { if ($oldrecord eq $record) { return; } -# warn "MARCmoditem : ".$record->as_formatted; -# warn "OLD : ".$oldrecord->as_formatted; # otherwise, skip through each subfield... my @fields = $record->fields(); diff --git a/MARCdetail.pl b/MARCdetail.pl index f8218279f5..d82dce9684 100755 --- a/MARCdetail.pl +++ b/MARCdetail.pl @@ -88,23 +88,27 @@ for (my $tabloop = 0; $tabloop<=10;$tabloop++) { my @fields = $record->fields(); my @loop_data =(); foreach my $field (@fields) { - my @subf=$field->subfields; -# my $previous_tag = ''; - my @subfields_data; -# loop through each subfield - for my $i (0..$#subf) { -# $previous_tag = $field->tag(); - $subf[$i][0] = "@" unless $subf[$i][0]; - next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne $tabloop); + my @subfields_data; + # if tag <10, there's no subfield, use the "@" trick + if ($field->tag()<10) { + next if ($tagslib->{$field->tag()}->{'@'}->{tab} ne $tabloop); my %subfield_data; - $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib}; - if ($field->tag()<10) { - $subfield_data{marc_value}=$field->data(); - } else { - $subfield_data{marc_value}=$subf[$i][1]; - } - $subfield_data{marc_tag}=$subf[$i][0]; + $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{'@'}->{lib}; + $subfield_data{marc_value}=$field->data(); + $subfield_data{marc_tag}='@'; push(@subfields_data, \%subfield_data); + } else { + my @subf=$field->subfields; + # loop through each subfield + for my $i (0..$#subf) { + $subf[$i][0] = "@" unless $subf[$i][0]; + next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne $tabloop); + my %subfield_data; + $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib}; + $subfield_data{marc_value}=$subf[$i][1]; + $subfield_data{marc_tag}=$subf[$i][0]; + push(@subfields_data, \%subfield_data); + } } if ($#subfields_data>=0) { my %tag_data; @@ -124,6 +128,7 @@ my @fields = $record->fields(); my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code my @big_array; foreach my $field (@fields) { + next if ($field->tag()<10); my @subf=$field->subfields; my %this_row; # loop through each subfield @@ -140,7 +145,6 @@ foreach my $field (@fields) { foreach my $subfield_code (keys(%witness)) { for (my $i=0;$i<=$#big_array;$i++) { $big_array[$i]{$subfield_code}=" " unless ($big_array[$i]{$subfield_code}); -# warn "filled : ".$big_array[$i]{$subfield_code}; } } # now, construct template ! @@ -151,7 +155,6 @@ for (my $i=0;$i<=$#big_array; $i++) { foreach my $subfield_code (keys(%witness)) { $items_data .="".$big_array[$i]{$subfield_code}.""; } -# warn $items_data; my %row_data; $row_data{item_value} = $items_data; push(@item_value_loop,\%row_data); diff --git a/acqui.simple/additem.pl b/acqui.simple/additem.pl index d89330ee7e..5102006684 100755 --- a/acqui.simple/additem.pl +++ b/acqui.simple/additem.pl @@ -32,7 +32,6 @@ use MARC::File::USMARC; sub find_value { my ($tagfield,$insubfield,$record) = @_; -# warn "$tagfield / $insubfield // "; my $result; my $indicator; foreach my $field ($record->field($tagfield)) { @@ -121,6 +120,7 @@ my @big_array; my ($itemtagfield,$itemtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.itemnumber"); my @itemnums; # array to store itemnums foreach my $field (@fields) { + next if ($field->tag()<10); my @subf=$field->subfields; my %this_row; # loop through each subfield -- 2.39.5