From 4a55018ff6b2fe9ad104aeb30930460a70d20271 Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Tue, 20 Jan 2009 19:18:20 -0600 Subject: [PATCH] Block warning on detail.pl. If Amazon doesn't have an avg. rating number defined, then we cannot multiply it by 20 without the following warning: detail.pl: Use of uninitialized value in multiplication (*) at /home/user/kohaclone/catalogue/detail.pl line 228. So the important part of this patch is || 0 on the $average_rating assignment. Signed-off-by: Henri-Damien LAURENT --- catalogue/detail.pl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 393ec16691..d21b8a7a4d 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -210,8 +210,8 @@ if (C4::Context->preference("FRBRizeEditions")==1) { if ( C4::Context->preference("AmazonContent") == 1 ) { my $similar_products_exist; my $amazon_details = &get_amazon_details( $xisbn, $record, $marcflavour ); - my $item_attributes = \%{$amazon_details->{Items}->{Item}->{ItemAttributes}}; - my $customer_reviews = \@{$amazon_details->{Items}->{Item}->{CustomerReviews}->{Review}}; + my $item_attributes = \%{$amazon_details->{Items}->{Item}->{ItemAttributes}}; + my $customer_reviews = \@{$amazon_details->{Items}->{Item}->{CustomerReviews}->{Review}}; my @similar_products; for my $similar_product (@{$amazon_details->{Items}->{Item}->{SimilarProducts}->{SimilarProduct}}) { # do we have any of these isbns in our collection? @@ -223,11 +223,11 @@ if ( C4::Context->preference("AmazonContent") == 1 ) { } } my $editorial_reviews = \@{$amazon_details->{Items}->{Item}->{EditorialReviews}->{EditorialReview}}; - my $average_rating = $amazon_details->{Items}->{Item}->{CustomerReviews}->{AverageRating}; - $template->param( AmazonSimilarItems => $similar_products_exist ); - $template->param( amazon_average_rating => $average_rating * 20); - $template->param( AMAZON_CUSTOMER_REVIEWS => $customer_reviews ); - $template->param( AMAZON_SIMILAR_PRODUCTS => \@similar_products ); - $template->param( AMAZON_EDITORIAL_REVIEWS => $editorial_reviews ); + my $average_rating = $amazon_details->{Items}->{Item}->{CustomerReviews}->{AverageRating} || 0; + $template->param( AmazonSimilarItems => $similar_products_exist ); + $template->param( amazon_average_rating => $average_rating * 20 ); + $template->param( AMAZON_CUSTOMER_REVIEWS => $customer_reviews ); + $template->param( AMAZON_SIMILAR_PRODUCTS => \@similar_products ); + $template->param( AMAZON_EDITORIAL_REVIEWS => $editorial_reviews ); } output_html_with_http_headers $query, $cookie, $template->output; -- 2.39.5