From fef2a118e29e22ad2da8d5c0ff12b38041eb2822 Mon Sep 17 00:00:00 2001 From: Brendan Lawlor Date: Mon, 18 May 2026 17:34:42 +0000 Subject: [PATCH] Bug 42637: Check if biblio exists before checking if it is fast add This patch reorders code to make sure the biblio record exists before checking if the framework is a fast add framework. To test: 1. Go to a non existing biblio record like: http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=99999999 2. See a 500 error or in ktd: Can't call method "frameworkcode" on an undefined value 3. Apply patch and restart_all 4. Repeat step 1 5. Now you get the nice error message: The record you requested does not exist (99999999). Signed-off-by: David Nind Signed-off-by: Lucas Gass --- catalogue/detail.pl | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 4466957b4f..40c2604663 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -90,18 +90,7 @@ if ( C4::Context->config('enable_plugins') ) { my $activetab = $query->param('activetab'); my $biblionumber = $query->param('biblionumber'); $biblionumber = HTML::Entities::encode($biblionumber); -my $biblio = Koha::Biblios->find($biblionumber); -my $frameworkcode = $biblio->frameworkcode; -my $is_fast_add = - $frameworkcode eq '' - ? 0 - : Koha::BiblioFrameworks->find($frameworkcode)->is_fast_add; - -$template->param( - biblio => $biblio, - activetab => $activetab, - is_fast_add => $is_fast_add, -); +my $biblio = Koha::Biblios->find($biblionumber); unless ($biblio) { @@ -114,6 +103,18 @@ unless ($biblio) { exit; } +my $frameworkcode = $biblio->frameworkcode; +my $is_fast_add = + $frameworkcode eq '' + ? 0 + : Koha::BiblioFrameworks->find($frameworkcode)->is_fast_add; + +$template->param( + biblio => $biblio, + activetab => $activetab, + is_fast_add => $is_fast_add, +); + my $marc_record = eval { $biblio->metadata->record }; my $invalid_marc_record = $@ || !$marc_record; if ($invalid_marc_record) {