From 3a4b2376cace62154c57322cc8c262380c365d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= Date: Thu, 26 Feb 2026 09:12:52 -0300 Subject: [PATCH] Bug 41944: Fix template error for non-existent ILL requests This patch fixes a template error that occurred when attempting to view a non-existent ILL request in the staff interface. Previously, navigating to ill-requests.pl with an invalid illrequest_id would result in a 500 error and a stacktrace. This change introduces a check for the existence of the ILL request immediately after retrieval. If no request is found, the script now redirects to the standard 404 error page, providing a graceful exit and preventing internal errors. Test plan: 1. Ensure KTD is launched with Rapido ILL plugin and bootstrapped (do NOT apply this patch yet): $ ktd --proxy --name rapido --single-plugin ~/git/koha-plugins/rapido-ill up -d $ ktd --shell k$ cd /kohadevbox/plugins/rapido-ill/scripts k$ perl bootstrap_rapido_testing.pl k$ restart_all 2. Log into the staff interface at http://rapido-intra.localhost. 3. Point your browser to a non-existent ILL request, e.g., http://rapido-intra.localhost/cgi-bin/koha/ill/ill-requests.pl?op=illview&illrequest_id=1000 => FAIL: Template errors and a stacktrace are displayed, or a 500 error in production logs. 4. Apply this patch. 5. Repeat step 3. => SUCCESS: The browser redirects to a 404 Not Found page, and no template errors or stacktraces are displayed. 6. Sign off :-D Signed-off-by: David Nind --- ill/ill-requests.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index d1b671fdc7..044ac8ab33 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -102,6 +102,11 @@ if ($backends_available) { # View the details of an ILL my $request = Koha::ILL::Requests->find( $params->{illrequest_id} ); + unless ($request) { + print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); + exit; + } + # Get the details for notices that can be sent from here my $notices = Koha::Notice::Templates->search( { -- 2.39.5