bugfix: handle subfield $0 in MARC for an item
authorGalen Charlton <galen.charlton@liblime.com>
Tue, 27 Nov 2007 20:08:06 +0000 (14:08 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Tue, 27 Nov 2007 21:52:41 +0000 (15:52 -0600)
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 <jmf@liblime.com>
C4/Biblio.pm

index 6444c3c..7559ee2 100755 (executable)
@@ -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);