From a447287e7c3471ad4e3e85ea381312d1cfcd8c73 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Thu, 18 Aug 2016 16:33:00 +0000
Subject: [PATCH] Bug 16272 [QA Followup] - Indexer fails on indexing temparary
 testing records

---
 Koha/ElasticSearch/Indexer.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Koha/ElasticSearch/Indexer.pm b/Koha/ElasticSearch/Indexer.pm
index 258c6c5..3c6d144 100644
--- a/Koha/ElasticSearch/Indexer.pm
+++ b/Koha/ElasticSearch/Indexer.pm
@@ -177,8 +177,10 @@ sub _sanitise_records {
         # the Tannhauser gate. MARC records where 999$c doesn't match the
         # biblionumber column. All those moments will be lost in time... like
         # tears in rain...
-        $rec->delete_fields($rec->field('999'));
-        $rec->append_fields(MARC::Field->new('999','','','c' => $bibnum, 'd' => $bibnum));
+        if ( $rec ) {
+            $rec->delete_fields($rec->field('999'));
+            $rec->append_fields(MARC::Field->new('999','','','c' => $bibnum, 'd' => $bibnum));
+        }
     }
 }
 
-- 
2.1.4