Bug 19319: Only fetch the record if it exists
[srvgit] / opac / opac-detail.pl
index 745c49c..bdef7d8 100755 (executable)
@@ -95,6 +95,8 @@ if ( ! $record ) {
     print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
     exit;
 }
+
+my $biblio = Koha::Biblios->find( $biblionumber );
 my $framework = &GetFrameworkCode( $biblionumber );
 my $record_processor = Koha::RecordProcessor->new({
     filters => 'ViewPolicy',
@@ -136,7 +138,7 @@ if (C4::Context->preference('OpacSuppression')) {
     }
 }
 
-$template->param( biblionumber => $biblionumber );
+$template->param( biblio => $biblio );
 
 # get biblionumbers stored in the cart
 my @cart_list;
@@ -603,7 +605,6 @@ for ( C4::Context->preference("OPACShowHoldQueueDetails") ) {
 }
 my $has_hold;
 if ( $show_holds_count || $show_priority) {
-    my $biblio = Koha::Biblios->find( $biblionumber );
     my $holds = $biblio->holds;
     $template->param( holds_count  => $holds->count );
     while ( my $hold = $holds->next ) {
@@ -844,13 +845,15 @@ if ( C4::Context->preference('reviewson') ) {
         my $patron = Koha::Patrons->find( $review->{borrowernumber} );
 
         # setting some borrower info into this hash
-        $review->{patron} = $patron;
-        if ( $libravatar_enabled and $patron and $patron->email ) {
-            $review->{avatarurl} = libravatar_url( email => $patron->email, https => $ENV{HTTPS} );
-        }
+        if ( $patron ) {
+            $review->{patron} = $patron;
+            if ( $libravatar_enabled and $patron->email ) {
+                $review->{avatarurl} = libravatar_url( email => $patron->email, https => $ENV{HTTPS} );
+            }
 
-        if ( $patron and $patron->borrowernumber eq $borrowernumber ) {
-            $loggedincommenter = 1;
+            if ( $patron->borrowernumber eq $borrowernumber ) {
+                $loggedincommenter = 1;
+            }
         }
     }
 }