bug 2659: fix crash in OAI-PMH interface
authorGalen Charlton <galen.charlton@liblime.com>
Mon, 6 Oct 2008 01:40:24 +0000 (20:40 -0500)
committerGalen Charlton <galen.charlton@liblime.com>
Thu, 16 Oct 2008 19:47:13 +0000 (14:47 -0500)
When retrieving a record via the OAI-PMH interface, if one of the fields used
to prepare the DC metadata is not defined in the MARC framework (e.g.,
biblioitems.publicationyear in the default MARC21 framework), an OAI GetRecord
can fail with the following error:

> Can't call method "as_string" on an undefined value at
> /usr/share/koha/opac/cgi-bin/opac/oai.pl line 59.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
opac/oai.pl

index 44b7367..532c3b8 100755 (executable)
@@ -56,6 +56,7 @@ my @result = ();
 
         foreach my $kohafield ( @_ ) {
                 my ( $field, $subfield ) = ::GetMarcFromKohaField( $kohafield, '' );
+                next unless defined $field; # $kohafield not defined in framework
                 push( @result, $field < 10 ? $marc->field( $field )->as_string() : $marc->subfield( $field, $subfield ) );
         }
 #        @result>1 ? \@result : $result[0];