[Koha-patches] [PATCH] kohabug 2141 - avoid carp on display of details of deleted bib

Galen Charlton galen.charlton at liblime.com
Mon May 19 21:28:36 CEST 2008


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.
---
 catalogue/detail.pl |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/catalogue/detail.pl b/catalogue/detail.pl
index f753e66..782a10d 100755
--- a/catalogue/detail.pl
+++ b/catalogue/detail.pl
@@ -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 );
-- 
1.5.5.rc0.16.g02b00




More information about the Koha-patches mailing list