From adb8be69d5c1a3ab2b826fae1ff5e2f9e64e5c56 Mon Sep 17 00:00:00 2001
From: Mark Tompsett <mtompset@hotmail.com>
Date: Sun, 10 Nov 2013 23:26:43 -0500
Subject: [PATCH] Bug 11183 - Warnings in opac

This may affect staff as well. During testing of Srdjan
Jankovic's patch, the following error message was triggered:
    opac-search.pl: Use of uninitialized value $code_wanted
in string eq at /usr/share/perl5/MARC/Field.pm line 314.

This was traced to a bad call on subfields in C4::Search. By
adding an if check around the call, this warning is no longer
triggered.

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
---
 C4/Search.pm |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/C4/Search.pm b/C4/Search.pm
index dd844e3..1afff1d 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -1842,7 +1842,9 @@ sub searchResults {
 
             # populate the items hash
             foreach my $code ( keys %subfieldstosearch ) {
-                $item->{$code} = $field->subfield( $subfieldstosearch{$code} );
+                if ( defined( $subfieldstosearch{$code} ) ) {
+                    $item->{$code} = $field->subfield( $subfieldstosearch{$code} );
+                }
             }
             $item->{description} = $itemtypes{ $item->{itype} }{description};
 
-- 
1.7.2.5