kohabug 2141 - avoid carp on display of details of deleted bib
authorGalen Charlton <galen.charlton@liblime.com>
Mon, 19 May 2008 19:28:36 +0000 (14:28 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Mon, 19 May 2008 21:07:08 +0000 (16:07 -0500)
When displaying details of bib in staff interface, check
that bib actually exists and display 404 page if not.  Avoids
following fatal error:

Can't call method "field" on an undefined value at /home/gmc/koha/dev/C4/Biblio.pm line 944.

This situtation can arise when running Zebra; if a bib is deleted,
Zebra will not necessarily be reindexed instantly, allowing a link
from a search result list to point to a missing record.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
catalogue/detail.pl

index f753e66..782a10d 100755 (executable)
@@ -53,6 +53,12 @@ my $fw = GetFrameworkCode($biblionumber);
 ## get notes and subjects from MARC record
 my $marcflavour      = C4::Context->preference("marcflavour");
 my $record           = GetMarcBiblio($biblionumber);
+
+unless (defined($record)) {
+    print $query->redirect("/cgi-bin/koha/errors/404.pl");
+       exit;
+}
+
 my $marcnotesarray   = GetMarcNotes( $record, $marcflavour );
 my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
 my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
@@ -70,11 +76,6 @@ my $dbh = C4::Context->dbh;
 my @items = &GetItemsInfo( $biblionumber, 'intra' );
 my $dat = &GetBiblioData($biblionumber);
 
-if (!$dat) { 
-    print $query->redirect("/cgi-bin/koha/koha-tmpl/errors/404.pl");
-       exit;
-}
-
 #coping with subscriptions
 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
 my @subscriptions       = GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber );