From c86e5be9233c948b6ef1c88e7305bf93fa54ac84 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 10 Jan 2020 08:51:51 +0000 Subject: [PATCH] Bug 24367: Resolve other uninitialized warns in Search.pm Content-Type: text/plain; charset=utf-8 Use of uninitialized value in hash element at /usr/share/koha/C4/Search.pm line 2074. Use of uninitialized value in hash element at /usr/share/koha/C4/Search.pm line 2137. Use of uninitialized value in concatenation (.) or string at /usr/share/koha/C4/Search.pm line 2189. Use of uninitialized value in hash element at /usr/share/koha/C4/Search.pm line 2213. Use of uninitialized value in hash element at /usr/share/koha/C4/Search.pm line 2215. Use of uninitialized value in hash element at /usr/share/koha/C4/Search.pm line 2225. Use of uninitialized value in hash element at /usr/share/koha/C4/Search.pm line 2226. --- C4/Search.pm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index d1df39defb..532116d703 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -2071,7 +2071,7 @@ sub searchResults { foreach my $code ( keys %subfieldstosearch ) { $item->{$code} = $field->subfield( $subfieldstosearch{$code} ); } - $item->{description} = $itemtypes{ $item->{itype} }{translated_description}; + $item->{description} = $itemtypes{ $item->{itype} }{translated_description} if $item->{itype}; # OPAC hidden items if ($is_opac) { @@ -2134,7 +2134,9 @@ sub searchResults { # items not on loan, but still unavailable ( lost, withdrawn, damaged ) else { - $item->{notforloan}=1 if !$item->{notforloan} && $itemtypes{ C4::Context->preference("item-level_itypes")? $item->{itype}: $oldbiblio->{itemtype} }->{notforloan}; + my $itemtype = C4::Context->preference("item-level_itypes")? $item->{itype}: $oldbiblio->{itemtype}; + $item->{notforloan} = 1 if !$item->{notforloan} && + $itemtype && $itemtypes{ $itemtype }->{notforloan}; # item is on order if ( $item->{notforloan} < 0 ) { @@ -2184,9 +2186,9 @@ sub searchResults { $withdrawn_count++ if $item->{withdrawn}; $itemlost_count++ if $item->{itemlost}; $itemdamaged_count++ if $item->{damaged}; - $item_in_transit_count++ if $transfertwhen ne ''; + $item_in_transit_count++ if $transfertwhen && $transfertwhen ne ''; $item_onhold_count++ if $reservestatus eq 'Waiting'; - $item->{status} = $item->{withdrawn} . "-" . $item->{itemlost} . "-" . $item->{damaged} . "-" . $item->{notforloan}; + $item->{status} = ($item->{withdrawn}//q{}) . "-" . ($item->{itemlost}//q{}) . "-" . ($item->{damaged}//q{}) . "-" . ($item->{notforloan}//q{}); # can place a hold on a item if # not lost nor withdrawn @@ -2210,9 +2212,9 @@ sub searchResults { $other_items->{$key}->{onhold} = ($reservestatus) ? 1 : 0; $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan}; $other_items->{$key}->{count}++ if $item->{$hbranch}; - $other_items->{$key}->{location} = $shelflocations->{ $item->{location} }; + $other_items->{$key}->{location} = $shelflocations->{ $item->{location} } if $item->{location}; $other_items->{$key}->{description} = $item->{description}; - $other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype} }->{imageurl} ); + $other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype}//q{} }->{imageurl} ); } # item is available else { @@ -2222,8 +2224,8 @@ sub searchResults { foreach (qw(branchname itemcallnumber description)) { $available_items->{$prefix}->{$_} = $item->{$_}; } - $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} }; - $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype} }->{imageurl} ); + $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} } if $item->{location}; + $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype}//q{} }->{imageurl} ); } } } # notforloan, item level and biblioitem level -- 2.11.0