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 <galen.charlton@liblime.com>
This commit is contained in:
Galen Charlton 2009-04-08 15:34:45 -05:00
parent 74cb2f666e
commit 6a2a4e146e
4 changed files with 4 additions and 4 deletions

View File

@ -1302,7 +1302,7 @@ sub GetMarcUrls {
};
$marcurl->{'linktext'} = $link || $s3 || C4::Context->preference('URLLinkText') || $url;
$marcurl->{'part'} = $s3 if ($link);
$marcurl->{'toc'} = 1 if ( $s3 =~ /^[Tt]able/ );
$marcurl->{'toc'} = 1 if ( defined($s3) && $s3 =~ /^[Tt]able/ );
} else {
$marcurl->{'linktext'} = $field->subfield('2') || C4::Context->preference('URLLinkText') || $url;
$marcurl->{'MARCURL'} = $url;

View File

@ -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;
}

View File

@ -238,7 +238,7 @@ if ( C4::Context->preference("AmazonEnabled") == 1 ) {
}
}
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( AmazonSimilarItems => $similar_products_exist );
$template->param( amazon_average_rating => $average_rating * 20);
$template->param( AMAZON_CUSTOMER_REVIEWS => $customer_reviews );

View File

@ -286,7 +286,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 );