From e948906c83e7ab649337b4048064c52adf99b767 Mon Sep 17 00:00:00 2001 From: Andreas Jonsson Date: Mon, 12 Feb 2024 11:16:02 +0000 Subject: [PATCH] Bug 35930: Add guards for plugins_enabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The 'new' method in Koha::Plugins returns undefined if plugins are disabled. Therefore, calls to this method must be guarded by a check that plugins actually are enabled. Test plan: * Code inspection of patch, alternatively * Activate the ill system by installing a backend such as koha-illbackend-libris: https://github.com/Libriotech/koha-illbackend-libris * Make sure plugins are disabled in koha-conf.xml * In the staff interface, go to ILL requests. * The page should load without getting an error 500. PA amended commit message: This is not related to ILL backends being plugins or not This is about ILL batches, where checking for metadata enrichment plugins was missing 'enable_plugins' guard Additionally, unrelated to batches, it's also about ILLAvailability, where checking for ILL availabililty plugins was missing enable_plugins guard Signed-off-by: Pedro Amorim Signed-off-by: Tomas Cohen Arazi Signed-off-by: Hans PÃ¥lsson Signed-off-by: Martin Renvoize (cherry picked from commit fee4368cd81e4318bed14f0a082c978badca4256) Signed-off-by: Fridolin Somers --- Koha/Illrequest/Workflow/Availability.pm | 2 ++ ill/ill-requests.pl | 1 + 2 files changed, 3 insertions(+) diff --git a/Koha/Illrequest/Workflow/Availability.pm b/Koha/Illrequest/Workflow/Availability.pm index 4fd75a48a9..bcc50f6fe7 100644 --- a/Koha/Illrequest/Workflow/Availability.pm +++ b/Koha/Illrequest/Workflow/Availability.pm @@ -64,6 +64,8 @@ sub get_services { $plugin_filter->{metadata} = $params->{metadata}; } + return [] unless C4::Context->config("enable_plugins"); + my @candidates = Koha::Plugins->new()->GetPlugins($plugin_filter); my @services = (); foreach my $plugin (@candidates) { diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index 9912bc7f16..2a1ed67848 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -531,6 +531,7 @@ sub can_batch { # Get available metadata enrichment plugins sub get_metadata_enrichment { + return [] unless C4::Context->config("enable_plugins"); my @candidates = Koha::Plugins->new()->GetPlugins({ method => 'provides_api' }); -- 2.39.5