From 9249a84dcdc4fb6805b1e20d2e7cf16bddd314f8 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 20 Oct 2025 15:33:04 +0000 Subject: [PATCH] Bug 41057: Return 404 if creating backend is not an OPAC backend Test plan, ktd: 1) Enable ILLModule 2) Install an additional backend plugin e.g. 'RapidILL': https://github.com/openfifth/koha-ill-rapidill/releases/tag/v2.2.5 3) Restart plack if you have to: $ koha-plack --restart kohadev 4) Edit the ILLOpacbackends system preference to just 'Standard'. 5) Now, attempt to create a request with the installed backend directly: /cgi-bin/koha/opac-illrequests.pl?op=add_form&backend=RapidILL 6) Notice the form is shown. It shouldn't be, as the only OPAC back is Standard. 7) Apply patch. Repeat. You get a 404. --- opac/opac-illrequests.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opac/opac-illrequests.pl b/opac/opac-illrequests.pl index b089c29d6f2..4ed2f086266 100755 --- a/opac/opac-illrequests.pl +++ b/opac/opac-illrequests.pl @@ -48,7 +48,10 @@ my $query = CGI->new; our $params = $query->Vars(); # if illrequests is disabled, leave immediately -if ( !C4::Context->preference('ILLModule') ) { +my $opac_backends = Koha::ILL::Request::Config->new->opac_available_backends(); +if ( !C4::Context->preference('ILLModule') + || ( $params->{backend} && !grep { $_ eq $params->{backend} } @$opac_backends ) ) +{ print $query->redirect("/cgi-bin/koha/errors/404.pl"); exit; } -- 2.39.5