Bug 23248: Avoid opac-ISBDdetail.pl breaking on invalid biblionumber
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 1 Jul 2019 18:52:02 +0000 (15:52 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 5 Jul 2019 07:35:51 +0000 (08:35 +0100)
This patch makes opac-ISBDdetail.pl redirect to a 404 page (as it
should) in the event of a bad biblionumber passed.

To test:
- Open your browser on a known record detail page (OPAC)
- Switch to the ISBD view
=> SUCCESS: It shows
- Alter the biblionumber on the URL into an obviously non-existent
biblionumber (e.g. very high value)
=> FAIL: Internal errors are shown
- Apply this patch
- Reload the bad biblionumber ISBD view
=> SUCCESS: Browser is redirected to the 404 page as it should
- Sign off :-=> FAIL: Internal errors are shown
- Apply this patch
- Reload the bad biblionumber ISBD view
=> SUCCESS: Browser is redirected to the 404 page as it should
- Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

opac/opac-ISBDdetail.pl

index e4a0b3f..4305d8c 100755 (executable)
@@ -76,8 +76,12 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
-
 my $biblio = Koha::Biblios->find( $biblionumber, { prefetch => [ 'metadata', 'items' ] } );
+unless ( $biblio ) {
+    print $query->redirect("/cgi-bin/koha/errors/404.pl");
+    exit;
+}
+
 my $patron = Koha::Patrons->find($loggedinuser);
 
 my $opachiddenitems_rules;