Bugzilla – Attachment 152699 Details for
Bug 34121
Improve performance of Koha::Plugins::call
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34121: Filter enabled plugins for the given method
Bug-34121-Filter-enabled-plugins-for-the-given-met.patch (text/plain), 2.14 KB, created by
Kyle M Hall (khall)
on 2023-06-26 15:48:40 UTC
(
hide
)
Description:
Bug 34121: Filter enabled plugins for the given method
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-06-26 15:48:40 UTC
Size:
2.14 KB
patch
obsolete
>From 68e4d2a3878fc3b7097311194e2b34763387e5bc Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 26 Jun 2023 15:46:56 +0000 >Subject: [PATCH] Bug 34121: Filter enabled plugins for the given method > >--- > Koha/Plugins.pm | 21 ++++++++++++++++++--- > 1 file changed, 18 insertions(+), 3 deletions(-) > >diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm >index a3c47006b5..e2e923f8bc 100644 >--- a/Koha/Plugins.pm >+++ b/Koha/Plugins.pm >@@ -80,7 +80,7 @@ sub call { > return unless C4::Context->config('enable_plugins'); > > my @responses; >- my @plugins = $class->get_enabled_plugins(); >+ my @plugins = $class->get_enabled_plugins($method); > @plugins = grep { $_->can($method) } @plugins; > > # TODO: Remove warn when after_hold_create is removed from the codebase >@@ -104,12 +104,12 @@ sub call { > > Returns a list of enabled plugins. > >- @plugins = Koha::Plugins->get_enabled_plugins(); >+ @plugins = Koha::Plugins->get_enabled_plugins([$method]); > > =cut > > sub get_enabled_plugins { >- my ($class) = @_; >+ my ( $class, $method ) = @_; > > return unless C4::Context->config('enable_plugins'); > >@@ -119,6 +119,21 @@ sub get_enabled_plugins { > my $rs = Koha::Database->schema->resultset('PluginData'); > $rs = $rs->search({ plugin_key => '__ENABLED__', plugin_value => 1 }); > my @plugin_classes = $rs->get_column('plugin_class')->all(); >+ >+ # Filter any enabled plugins that don't have the given method if one was passed in >+ if ($method) { >+ my @plugin_classes_with_method = Koha::Plugins::Methods->search( >+ { method => $method }, >+ { >+ columns => 'plugin_class', >+ distinct => 1 >+ } >+ )->as_list; >+ >+ my %seen = map { $_ => 1 } @plugin_classes; >+ my @plugin_classes = grep { $seen{$_} } @plugin_classes_with_method; >+ } >+ > foreach my $plugin_class (@plugin_classes) { > unless (can_load(modules => { $plugin_class => undef }, nocache => 1)) { > warn "Failed to load $plugin_class: $Module::Load::Conditional::ERROR"; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34121
: 152699 |
152700