From fe9106af0bce38d9a380d859a6429584718268d2 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 27 Nov 2007 14:08:06 -0600 Subject: [PATCH] bugfix: handle subfield $0 in MARC for an item Note: C4::Biblio::GetMarcFromKohaField returns (0, 0) if the kohafield is not defined in the MARC framework, but in may places the return value is not checked correctly and does not recognize a subfield $0 (zero). It would be better if GetMarcFromKohaField returned (undef, undef) in that circumstance, but because of the number of places where that function is used, the changed is deferred for post 3.0. Signed-off-by: Joshua Ferraro --- C4/Biblio.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 6444c3c56b..7559ee2177 100755 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -465,7 +465,14 @@ sub ModItemInMarconefield { my $record = GetMarcItem( $biblionumber, $itemnumber ); my ($tagfield, $tagsubfield) = GetMarcFromKohaField( $itemfield,''); - if ($tagfield && $tagsubfield) { + # FIXME - the condition is done this way because GetMarcFromKohaField + # returns (0, 0) if it can't field a MARC tag for the kohafield. However, + # some fields like items.wthdrawn are mapped to subfield $0, making the + # customary test of "if ($tagfield && $tagsubfield)" incorrect. + # GetMarcFromKohaField should probably be returning (undef, undef), making + # the correct test "if (defined $tagfield && defined $tagsubfield)", but + # this would be a large change and consequently deferred for after 3.0. + if (not(int($tagfield) == 0 && int($tagsubfield) == 0)) { my $tag = $record->field($tagfield); if ($tag) { # my $tagsubs = $record->field($tagfield)->subfield($tagsubfield); -- 2.39.5