[open-ils-commits] r16925 - trunk/Open-ILS/src/perlmods/OpenILS/Application (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jul 13 18:09:25 EDT 2010
Author: dbs
Date: 2010-07-13 18:09:19 -0400 (Tue, 13 Jul 2010)
New Revision: 16925
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
Log:
Be more relaxed about what we receive in Vandelay (a bad LDR/09 need not lead to complete misery)
If MARC::File::XML->as_xml_record() receives a record with anything other
than 'a' in LDR/09 position, it will try to run a MARC8-to-UTF8 conversion
on the record - even though the source file itself was XML and clearly
couldn't have been MARC8.
This code corrects the leader on the fly so that MARC::File::XML won't
try to convert it and throw a "wide character" warning, but the fix
means that something was wrong with the leader to begin with, so we also
write a warning to the log about the situation.
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm 2010-07-13 20:27:45 UTC (rev 16924)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm 2010-07-13 22:09:19 UTC (rev 16925)
@@ -280,6 +280,15 @@
$logger->info("processing record $count");
try {
+ # Avoid an over-eager MARC::File::XML that may try to convert
+ # our record from MARC8 to UTF8 and break because the record
+ # is obviously already UTF8
+ my $ldr = $r->leader();
+ if (($marctype eq 'XML') && (substr($ldr, 9, 1) ne 'a')) {
+ $logger->warn("MARCXML record LDR/09 was not 'a'; record leader may be corrupt");
+ substr($ldr,9,1,'a');
+ $r->leader($ldr);
+ }
(my $xml = $r->as_xml_record()) =~ s/\n//sog;
$xml =~ s/^<\?xml.+\?\s*>//go;
$xml =~ s/>\s+</></go;
More information about the open-ils-commits
mailing list