Bugzilla – Attachment 90662 Details for
Bug 21073
Improve plugin performance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21073: (QA follow-up) Simplify logic
Bug-21073-QA-follow-up-Simplify-logic.patch (text/plain), 3.27 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-06-17 11:22:04 UTC
(
hide
)
Description:
Bug 21073: (QA follow-up) Simplify logic
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-06-17 11:22:04 UTC
Size:
3.27 KB
patch
obsolete
>From 6cb6d4ec26a985d6fd02940aaca2a611da6ae81b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 17 Jun 2019 08:07:03 -0300 >Subject: [PATCH] Bug 21073: (QA follow-up) Simplify logic > >This patch simplifies the logic inside GetPlugins so: >- It uses Koha::Plugins::Methods instead of plain SQL >- It doesn't do more DB calls than needed, by filtering on method in the > initial query to Koha::Plugins::Methods. > >It also relies on the (newly introduced) ->is_enabled method in >Koha::Plugins::Base, for better readability. > >To test: >- Run the tests and notice no behaviour changes are introduced. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Plugins.pm | 41 ++++++++++++++++++++++------------------- > 1 file changed, 22 insertions(+), 19 deletions(-) > >diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm >index be1d091631..9dc42c5155 100644 >--- a/Koha/Plugins.pm >+++ b/Koha/Plugins.pm >@@ -70,33 +70,33 @@ If you pass multiple keys in the metadata hash, all keys must match. > > sub GetPlugins { > my ( $self, $params ) = @_; >- my $method = $params->{method}; >+ >+ my $method = $params->{method}; > my $req_metadata = $params->{metadata} // {}; > >- my $dbh = C4::Context->dbh; >- my $plugin_classes = $dbh->selectcol_arrayref('SELECT DISTINCT(plugin_class) FROM plugin_methods'); >+ my $filter = ( $method ) ? { plugin_method => $method } : undef; >+ >+ my $plugin_classes = Koha::Plugins::Methods->search( >+ $filter, >+ { columns => 'plugin_class', >+ distinct => 1 >+ } >+ )->_resultset->get_column('plugin_class'); >+ > my @plugins; > > # Loop through all plugins that implement at least a method >- foreach my $plugin_class (@$plugin_classes) { >- # filter the plugin out by method >- next >- if $method >- && !Koha::Plugins::Methods->search( >- { plugin_class => $plugin_class, plugin_method => $method } )->count; >+ while ( my $plugin_class = $plugin_classes->next ) { > > load $plugin_class; >- my $plugin = $plugin_class->new({ enable_plugins => $self->{'enable_plugins'} }); >+ my $plugin = $plugin_class->new({ >+ enable_plugins => $self->{'enable_plugins'} >+ # loads even if plugins are disabled >+ # FIXME: is this for testing without bothering to mock config? >+ }); > >- my $plugin_enabled = $plugin->retrieve_data('__ENABLED__'); >- $plugin->{enabled} = $plugin_enabled; >- >- # Want all plugins. Not only enabled ones. >- if ( defined($params->{all}) && $params->{all} ) { >- $plugin_enabled = 1; >- } >- >- next unless $plugin_enabled; >+ next unless $plugin->is_enabled or >+ defined($params->{all}) && $params->{all}; > > # filter the plugin out by metadata > my $plugin_metadata = $plugin->get_metadata; >@@ -120,6 +120,9 @@ This method iterates through all plugins physically present on a system. > For each plugin module found, it will test that the plugin can be loaded, > and if it can, will store its available methods in the plugin_methods table. > >+NOTE: We re-load all plugins here as a protective measure in case someone >+has removed a plugin directly from the system without using the UI >+ > =cut > > sub InstallPlugins { >-- >2.22.0
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 21073
:
76955
|
76956
|
76957
|
76958
|
76973
|
88379
|
88380
|
88381
|
89247
|
89251
|
89252
|
89255
|
89256
|
89272
|
89273
|
89274
|
89275
|
89276
|
89277
|
89278
|
89279
|
89786
|
89800
|
89801
|
89802
|
89803
|
89804
|
89805
|
89806
|
89807
|
89808
|
90630
|
90631
|
90650
|
90651
|
90652
|
90653
|
90654
|
90655
|
90656
|
90657
|
90658
|
90659
|
90660
|
90661
|
90662
|
90663
|
90664
|
90724
|
90725
|
90726
|
90727
|
90728
|
90729
|
90730
|
90731
|
90732
|
90733
|
90734
|
90735
|
90736
|
90737
|
90738
|
90739
|
90759
|
90816