From 144378a198ea58d33b5ca122006d92a625357c66 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 19 May 2008 14:28:36 -0500 Subject: [PATCH] kohabug 2141 - avoid carp on display of details of deleted bib 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 --- catalogue/detail.pl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index f753e665d1..782a10d1ea 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 ); -- 2.20.1