[open-ils-commits] r13287 - trunk/Open-ILS/src/perlmods/OpenILS/Utils (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Jun 2 09:54:05 EDT 2009


Author: dbs
Date: 2009-06-02 09:54:04 -0400 (Tue, 02 Jun 2009)
New Revision: 13287

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHDParser.pm
Log:
Don't go stampeding towards the location subfields!

Return gracefully if the MFHD record contains no 852 field, rather than erroring out


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHDParser.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHDParser.pm	2009-06-01 20:45:28 UTC (rev 13286)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/MFHDParser.pm	2009-06-02 13:54:04 UTC (rev 13287)
@@ -54,7 +54,7 @@
 sub mfhd_to_hash {
 	my ($self, $mfhd_xml) = @_;
 
-	my $location;
+	my $location = '';
 	my $holdings = [];
 	my $supplements = [];
 	my $indexes = [];
@@ -68,9 +68,11 @@
 	my $marc = MARC::Record->new_from_xml($mfhd_xml);
 	my $mfhd = MFHD->new($marc);
 
-	foreach my $subfield_ref ($marc->field('852')->subfields) {
-		my ($subfield, $data) = @$subfield_ref;
-		$location .= $data . " -- ";
+	foreach my $field ($marc->field('852')) {
+		foreach my $subfield_ref ($field->subfields) {
+			my ($subfield, $data) = @$subfield_ref;
+			$location .= $data . " -- ";
+		}
 	}
 	$location =~ s/ -- $//;
 



More information about the open-ils-commits mailing list