From 90143bd46b380bdf570f144f000edce20a6f2d2d Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Wed, 13 Aug 2008 08:39:04 +0200 Subject: [PATCH] Using Warns would cause problems with NoZebra Signed-off-by: Henri-Damien LAURENT --- C4/Biblio.pm | 20 +++++++++++--------- C4/Items.pm | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index e66f58e3ff..093da14cea 100755 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1624,7 +1624,8 @@ sub TransformMarcToKoha { my ( $dbh, $record, $frameworkcode, $limit_table ) = @_; my $result; - + $limit_table=$limit_table||0; + unless (defined $inverted_field_map) { $inverted_field_map = _get_inverted_marc_field_map(); } @@ -2348,6 +2349,7 @@ sub _AddBiblioNoZebra { my $sth2=$dbh->prepare('SELECT biblionumbers FROM nozebra WHERE server=? AND indexname=? AND value=?'); foreach my $field ($record->fields()) { #parse each subfield + ###FIXME: impossible to index a 001-009 value with NoZebra next if $field->tag <10; foreach my $subfield ($field->subfields()) { my $tag = $field->tag(); @@ -2368,9 +2370,9 @@ sub _AddBiblioNoZebra { next unless $_; # skip empty values (multiple spaces) # if the entry is already here, improve weight # warn "managing $_"; - if ($result{$key}->{"$_"} =~ /$biblionumber,\Q$title\E\-(\d);/) { - my $weight=$1+1; - $result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d);//; + if ($result{$key}->{"$_"} =~ /$biblionumber,\Q$title\E\-(\d+);/) { + my $weight=$1 + 1; + $result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//g; $result{$key}->{"$_"} .= "$biblionumber,$title-$weight;"; } else { # get the value if it exist in the nozebra table, otherwise, create it @@ -2379,8 +2381,8 @@ sub _AddBiblioNoZebra { # it exists if ($existing_biblionumbers) { $result{$key}->{"$_"} =$existing_biblionumbers; - my $weight=$1+1; - $result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d);//; + my $weight=$1 + 1; + $result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//g; $result{$key}->{"$_"} .= "$biblionumber,$title-$weight;"; # create a new ligne for this entry } else { @@ -2400,9 +2402,9 @@ sub _AddBiblioNoZebra { foreach (split / /,$line) { next unless $_; # skip empty values (multiple spaces) # if the entry is already here, improve weight - if ($result{'__RAW__'}->{"$_"} =~ /$biblionumber,\Q$title\E\-(\d);/) { + if ($result{'__RAW__'}->{"$_"} =~ /$biblionumber,\Q$title\E\-(\d+);/) { my $weight=$1+1; - $result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d);//; + $result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//; $result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;"; } else { # get the value if it exist in the nozebra table, otherwise, create it @@ -2412,7 +2414,7 @@ sub _AddBiblioNoZebra { if ($existing_biblionumbers) { $result{'__RAW__'}->{"$_"} =$existing_biblionumbers; my $weight=$1+1; - $result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d);//; + $result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//; $result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;"; # create a new ligne for this entry } else { diff --git a/C4/Items.pm b/C4/Items.pm index 3aef697c5b..a59dc515f7 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1521,7 +1521,7 @@ sub GetMarcItem { # Tack on 'items.' prefix to column names so that TransformKohaToMarc will work. # Also, don't emit a subfield if the underlying field is blank. - my $mungeditem = { map { $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : () } keys %{ $itemrecord } }; + my $mungeditem = { map { defined($itemrecord->{$_}) ? ("items.$_" => $itemrecord->{$_}) : () } keys %{ $itemrecord } }; my $itemmarc = TransformKohaToMarc($mungeditem); my $unlinked_item_subfields = _parse_unlinked_item_subfields_from_xml($mungeditem->{'items.more_subfields_xml'}); -- 2.39.5