From 0c88af95bf91553e8c20026b4f3279864dda1247 Mon Sep 17 00:00:00 2001
From: Dan Scott <dan@coffeecode.net>
Date: Mon, 20 Jun 2011 10:56:44 -0400
Subject: [PATCH] Protect URI reingest from failure due to malformed XML

In an ideal world, there would be no malformed XML. But our world is the
real world of libraries, and while the well_formed_xml() protects
against malformed XML in Evergreen 2.0 systems, in some cases bad XML
has been able to find its way into Evergreen systems in the past.

A single biblio.record_entry row containing malformed XML in the marc
column will prevent the call to reingest URIs from succeeding. By
limiting the set of records to those with well-formed XML, we can
increase the chance of the URI reingest succeeding at the cost of more
processing time.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
---
 Open-ILS/src/sql/Pg/upgrade/0559.schema.biblio.extract_located_uris.sql | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Open-ILS/src/sql/Pg/upgrade/0559.schema.biblio.extract_located_uris.sql b/Open-ILS/src/sql/Pg/upgrade/0559.schema.biblio.extract_located_uris.sql
index bdb49bbbc6..85d62abc2b 100644
--- a/Open-ILS/src/sql/Pg/upgrade/0559.schema.biblio.extract_located_uris.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0559.schema.biblio.extract_located_uris.sql
@@ -133,7 +133,9 @@ BEGIN
             FROM asset.call_number acn
                 INNER JOIN asset.uri_call_number_map auricnm ON auricnm.call_number = acn.id
                 INNER JOIN asset.uri auri ON auri.id = auricnm.uri
+                INNER JOIN biblio.record_entry bre ON acn.record = bre.id
             WHERE auri.href = auri.label
+                AND xml_is_well_formed(bre.marc)
             GROUP BY acn.record
             ORDER BY acn.record
         ) AS rec_uris
-- 
2.11.0