Bug 19319: Only fetch the record if it exists
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 8 Dec 2017 17:57:15 +0000 (14:57 -0300)
committerChris Cormack <chrisc@catalyst.net.nz>
Wed, 20 Dec 2017 23:52:13 +0000 (12:52 +1300)
We already know if the bibliographic record exists (404 redirect),
we can avoid unecessary fetches

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

opac/opac-ISBDdetail.pl
opac/opac-detail.pl

index 78ff134..78cf48a 100755 (executable)
@@ -70,8 +70,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
 my $biblionumber = $query->param('biblionumber');
 $biblionumber = int($biblionumber);
 
-my $biblio = Koha::Biblios->find( $biblionumber );
-
 # get biblionumbers stored in the cart
 if(my $cart_list = $query->cookie("bib_list")){
     my @cart_list = split(/\//, $cart_list);
@@ -99,6 +97,9 @@ if ( ! $record ) {
     print $query->redirect("/cgi-bin/koha/errors/404.pl");
     exit;
 }
+
+my $biblio = Koha::Biblios->find( $biblionumber );
+
 my $framework = GetFrameworkCode( $biblionumber );
 my $record_processor = Koha::RecordProcessor->new({
     filters => 'ViewPolicy',
index 48f947e..93a0ab9 100755 (executable)
@@ -72,7 +72,6 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
 
 my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0;
 $biblionumber = int($biblionumber);
-my $biblio = Koha::Biblios->find( $biblionumber );
 
 my @all_items = GetItemsInfo($biblionumber);
 my @hiddenitems;
@@ -90,6 +89,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',