Block warning on detail.pl.
authorJoe Atzberger <joe.atzberger@liblime.com>
Wed, 21 Jan 2009 01:18:20 +0000 (19:18 -0600)
committerGalen Charlton <galen.charlton@liblime.com>
Fri, 24 Apr 2009 14:02:34 +0000 (09:02 -0500)
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.

[RM note: applying for whitespace cleanup]

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
catalogue/detail.pl

index 4529064..663f770 100755 (executable)
@@ -225,8 +225,8 @@ if (C4::Context->preference("FRBRizeEditions")==1) {
 if ( C4::Context->preference("AmazonEnabled") == 1 ) {
     my $similar_products_exist;
     my $amazon_details = &get_amazon_details( $isbn, $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?
@@ -239,10 +239,10 @@ if ( C4::Context->preference("AmazonEnabled") == 1 ) {
     }
     my $editorial_reviews = \@{$amazon_details->{Items}->{Item}->{EditorialReviews}->{EditorialReview}};
     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 );
+    $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;