From 0e959003351a1dc941fe9dc42b6878e8c618f173 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 20 May 2026 14:38:13 +0000 Subject: [PATCH] Bug 42653: get_backend_plugin should cache results per backend name The plugin cache used a single slot, so the first backend looked up poisoned it for all subsequent calls. This caused 500 errors when viewing ILL requests that had been migrated between backends. Test plan: 1) Download and install 2 additional plugin backends that implement their own templates: https://github.com/openfifth/koha-ill-libkey-lending-tool/releases/download/v2.6.1/koha-ill-libkey-lending-tool-v2.6.1.kpz https://github.com/openfifth/koha-ill-reprintsdesk/releases/download/v4.2.0/koha-ill-reprintsdesk-v4.2.0.kpz 2) Enable ILLModule and run the following SQL: INSERT INTO illrequests (borrowernumber, branchcode, status, backend, placed) SELECT b.borrowernumber, br.branchcode, 'COMP', 'ReprintsDesk', NOW() FROM borrowers b, branches br LIMIT 1; INSERT INTO action_logs (timestamp, user, module, action, object, info, interface) VALUES (NOW() - INTERVAL 2 HOUR, 1, 'ILL', 'INCDOCS_REQUEST_PLACED', 1, '{"log_origin":"IncDocs","response":1}', 'intranet'), (NOW() - INTERVAL 1 HOUR, 1, 'ILL', 'REPRINTS_DESK_REQUEST_ORDER_UPDATED', 1, '{"log_origin":"ReprintsDesk","response":null}', 'commandline'); 3) Attempt to open the 'Manage request' page for this newly created request: http://localhost:8081/cgi-bin/koha/ill/ill-requests.pl?op=illview&illrequest_id=1 4) Notice you get a 500 error: Template process failed: file error - : not found 5) Apply all patches, restart plack, refresh. Notice the 'Manage request' page now renders correctly. 6) Click the 'ILL request log' toolbar button. Confirm that both the IncDocs and ReprintsDesk entries are shown. Signed-off-by: Hannah Prince Signed-off-by: Andrew Fuerste Henry Signed-off-by: Pedro Amorim --- Koha/ILL/Request.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index 100f461ec8..072cc74828 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -450,7 +450,7 @@ Returns the installed I corresponding to the given backend_id or u sub get_backend_plugin { my ( $self, $backend_id ) = @_; - if ( !$self->{_plugin} ) { + if ( !$self->{_plugin}{$backend_id} ) { my $koha_plugins = Koha::Plugins->new(); my @backend_plugins = $koha_plugins ? Koha::Plugins->new()->GetPlugins( @@ -462,11 +462,11 @@ sub get_backend_plugin { ) : (); - $self->{_plugin} = $backend_plugins[0] + $self->{_plugin}{$backend_id} = $backend_plugins[0] if scalar @backend_plugins; } - return $self->{_plugin}; + return $self->{_plugin}{$backend_id}; } =head3 load_backend