From 7d1ac560bfacc083de963f827a8e1cbfe796d626 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 8 Apr 2009 15:34:45 -0500 Subject: [PATCH] fix various warnings * Use of uninitialized value in pattern match (m//) at C4/Biblio.pm line 1305 (displaying MARC21 856s that don't have $3) * Use of uninitialized value in multiplication (*) at catalogue/detail.pl line 243. (attemping to calculate average Amazon rating if no Amazon info is available) * opac-detail.pl: Use of uninitialized value in length at C4/External/Amazon.pm line 90 (attempting to calculate length of $isbn if it happens to be undef) Signed-off-by: Galen Charlton Signed-off-by: Henri-Damien LAURENT --- C4/Amazon.pm | 2 +- opac/opac-detail.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/Amazon.pm b/C4/Amazon.pm index 21ece8941e..34f98c2e31 100644 --- a/C4/Amazon.pm +++ b/C4/Amazon.pm @@ -87,7 +87,7 @@ sub get_amazon_details { # warn "ISBN: $isbn | UPC: $upc | EAN: $ean"; my ( $id_type, $item_id); - if (length($isbn) eq 13) { # if the isbn is 13-digit, search Amazon using EAN + if (defined($isbn) && length($isbn) == 13) { # if the isbn is 13-digit, search Amazon using EAN $id_type = 'EAN'; $item_id = $isbn; } diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index f132d3daad..4e6e4cae28 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -284,7 +284,7 @@ if ( C4::Context->preference("OPACAmazonEnabled") && C4::Context->preference("OP } } my $editorial_reviews = \@{$amazon_details->{Items}->{Item}->{EditorialReviews}->{EditorialReview}}; - my $average_rating = $amazon_details->{Items}->{Item}->{CustomerReviews}->{AverageRating}; + my $average_rating = $amazon_details->{Items}->{Item}->{CustomerReviews}->{AverageRating} || 0; $template->param( OPACAmazonSimilarItems => $similar_products_exist ); $template->param( amazon_average_rating => $average_rating * 20); $template->param( AMAZON_CUSTOMER_REVIEWS => $customer_reviews ); -- 2.39.5