From c9241f2f4d52172c052a77dce9963696c28fed8d Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 9 Mar 2011 10:12:49 -0300 Subject: [PATCH 3/3] [Bug 5791] (2/2) Error handling for ISBDdetail, MARCdetail and labeledMARCdetail Content-Type: text/plain; charset="utf-8" This follow-up completes what Owen requested on bugzilla for the bug to be closed. If anything remains let me know. To+ --- C4/Biblio.pm | 1 + catalogue/ISBDdetail.pl | 9 +++++++++ catalogue/MARCdetail.pl | 18 ++++++++++++++---- catalogue/labeledMARCdetail.pl | 15 ++++++++++++--- .../prog/en/modules/catalogue/ISBDdetail.tmpl | 11 +++++++---- .../prog/en/modules/catalogue/MARCdetail.tmpl | 9 ++++++--- .../en/modules/catalogue/labeledMARCdetail.tmpl | 10 ++++++++-- 7 files changed, 57 insertions(+), 16 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 8ea5da5..67e587b 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -751,6 +751,7 @@ Return the ISBD view which can be included in opac and intranet sub GetISBDView { my ( $biblionumber, $template ) = @_; my $record = GetMarcBiblio($biblionumber); + return undef unless defined $record; my $itemtype = &GetFrameworkCode($biblionumber); my ( $holdingbrtagf, $holdingbrtagsubf ) = &GetMarcFromKohaField( "items.holdingbranch", $itemtype ); my $tagslib = &GetMarcStructure( 1, $itemtype ); diff --git a/catalogue/ISBDdetail.pl b/catalogue/ISBDdetail.pl index 7ebe8e0..6dfccfd 100755 --- a/catalogue/ISBDdetail.pl +++ b/catalogue/ISBDdetail.pl @@ -70,6 +70,15 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( # my @fields = $record->fields(); my $res = GetISBDView($biblionumber, "intranet"); +if ( not defined $res ) { + # biblionumber invalid -> report and exit + $template->param( unknownbiblionumber => 1, + biblionumber => $biblionumber + ); + output_html_with_http_headers $query, $cookie, $template->output; + exit; +} + # count of item linked with biblio my $itemcount = GetItemsCount($biblionumber); $template->param( count => $itemcount); diff --git a/catalogue/MARCdetail.pl b/catalogue/MARCdetail.pl index d73c5d9..431ba43 100755 --- a/catalogue/MARCdetail.pl +++ b/catalogue/MARCdetail.pl @@ -68,10 +68,6 @@ my $popup = ; # if set to 1, then don't insert links, it's just to show the biblio my $subscriptionid = $query->param('subscriptionid'); -my $tagslib = &GetMarcStructure(1,$frameworkcode); - -my $record = GetMarcBiblio($biblionumber); -my $biblio = GetBiblioData($biblionumber); # open template my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -84,6 +80,20 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +my $record = GetMarcBiblio($biblionumber); + +if ( not defined $record ) { + # biblionumber invalid -> report and exit + $template->param( unknownbiblionumber => 1, + biblionumber => $biblionumber + ); + output_html_with_http_headers $query, $cookie, $template->output; + exit; +} + +my $tagslib = &GetMarcStructure(1,$frameworkcode); +my $biblio = GetBiblioData($biblionumber); + #count of item linked my $itemcount = GetItemsCount($biblionumber); $template->param( count => $itemcount, diff --git a/catalogue/labeledMARCdetail.pl b/catalogue/labeledMARCdetail.pl index e72a6d1..9560ef3 100755 --- a/catalogue/labeledMARCdetail.pl +++ b/catalogue/labeledMARCdetail.pl @@ -37,9 +37,6 @@ my $popup = $query->param('popup') ; # if set to 1, then don't insert links, it's just to show the biblio -my $tagslib = GetMarcStructure(1,$frameworkcode); -my $record = GetMarcBiblio($biblionumber); -my $biblio = GetBiblioData($biblionumber); # open template my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -52,6 +49,18 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +my $record = GetMarcBiblio($biblionumber); +if ( not defined $record ) { + # biblionumber invalid -> report and exit + $template->param( unknownbiblionumber => 1, + biblionumber => $biblionumber + ); + output_html_with_http_headers $query, $cookie, $template->output; + exit; +} +my $tagslib = GetMarcStructure(1,$frameworkcode); +my $biblio = GetBiblioData($biblionumber); + #count of item linked my $itemcount = GetItemsCount($biblionumber); $template->param( count => $itemcount, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tmpl index 1516268..f292085 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tmpl @@ -1,5 +1,5 @@ -Koha › Catalog › ISBD Details for <!-- TMPL_VAR NAME="title" --> +Koha › Catalog › <!-- TMPL_IF NAME="unknownbiblionumber" -->Unknown record<!-- TMPL_ELSE -->ISBD Details for <!-- TMPL_VAR NAME="title" --><!-- /TMPL_IF --> @@ -7,10 +7,13 @@ - +
- + + +
The record you requested does not exist ().
+
@@ -20,11 +23,11 @@
-
+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tmpl index f9cc90d..b2d9e6e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tmpl @@ -1,5 +1,5 @@ -Koha › Catalog › MARC Details for <!-- TMPL_VAR NAME="bibliotitle" --> +Koha › Catalog › <!-- TMPL_IF NAME="unknownbiblionumber" -->Unknown record<!-- TMPL_ELSE -->MARC Details for <!-- TMPL_VAR NAME="bibliotitle" --><!-- /TMPL_IF -->